mirror of
https://github.com/mirror/tinycc.git
synced 2025-01-15 05:20:06 +08:00
Fix argv/environ bound checking
This commit is contained in:
parent
8b8e714517
commit
70b16cb7f8
@ -945,7 +945,7 @@ __bound_main_arg(int argc, char **argv, char **envp)
|
|||||||
WAIT_SEM ();
|
WAIT_SEM ();
|
||||||
for (i = 0; i < argc; i++)
|
for (i = 0; i < argc; i++)
|
||||||
tree = splay_insert((size_t) argv[i], strlen (argv[i]) + 1, tree);
|
tree = splay_insert((size_t) argv[i], strlen (argv[i]) + 1, tree);
|
||||||
tree = splay_insert((size_t) argv, argc * sizeof(char *), tree);
|
tree = splay_insert((size_t) argv, (argc + 1) * sizeof(char *), tree);
|
||||||
POST_SEM ();
|
POST_SEM ();
|
||||||
#if BOUND_DEBUG
|
#if BOUND_DEBUG
|
||||||
if (print_calls) {
|
if (print_calls) {
|
||||||
@ -954,7 +954,7 @@ __bound_main_arg(int argc, char **argv, char **envp)
|
|||||||
__FILE__, __FUNCTION__,
|
__FILE__, __FUNCTION__,
|
||||||
argv[i], (unsigned long)(strlen (argv[i]) + 1));
|
argv[i], (unsigned long)(strlen (argv[i]) + 1));
|
||||||
dprintf(stderr, "%s, %s(): argv %p 0x%lx\n",
|
dprintf(stderr, "%s, %s(): argv %p 0x%lx\n",
|
||||||
__FILE__, __FUNCTION__, argv, argc * sizeof(char *));
|
__FILE__, __FUNCTION__, argv, (argc + 1) * sizeof(char *));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -967,7 +967,7 @@ __bound_main_arg(int argc, char **argv, char **envp)
|
|||||||
tree = splay_insert((size_t) *p, strlen (*p) + 1, tree);
|
tree = splay_insert((size_t) *p, strlen (*p) + 1, tree);
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
tree = splay_insert((size_t) envp, p - envp, tree);
|
tree = splay_insert((size_t) envp, (++p - envp) * sizeof(char *), tree);
|
||||||
POST_SEM ();
|
POST_SEM ();
|
||||||
#if BOUND_DEBUG
|
#if BOUND_DEBUG
|
||||||
if (print_calls) {
|
if (print_calls) {
|
||||||
@ -979,7 +979,7 @@ __bound_main_arg(int argc, char **argv, char **envp)
|
|||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
dprintf(stderr, "%s, %s(): environ %p 0x%lx\n",
|
dprintf(stderr, "%s, %s(): environ %p 0x%lx\n",
|
||||||
__FILE__, __FUNCTION__, envp, p - envp);
|
__FILE__, __FUNCTION__, envp, (++p - envp) * sizeof(char *));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user