* [PATCH] execve: Add envp to the Linux notes about NULL pointers
@ 2013-06-13 18:37 Peter LaDow
[not found] ` <CAN8Q1EdfNEyYMoMwu95ROZOCLg6t7ncQudqpV5c02n7H-073mA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Peter LaDow @ 2013-06-13 18:37 UTC (permalink / raw)
To: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-man-u79uwXL29TY76Z2rM5mHXA
This is my first patch submission. I've tried to follow the
directions found at https://www.kernel.org/doc/man-pages/patches.html,
but if I've screwed things up, please let me know.
During the review of static analysis results, we discovered a
functional, but non-portable, use of execve(). For example:
char *cmd[] = { "/path/to/some/file", NULL };
execve(cmd[0], cmd, NULL);
The call succeeds. Yet, the static analysis tool (rightly) pointed
out that envp could be dereferenced. But digging into glibc and the
kernel, it appears that like argv, envp when NULL is treated as if it
were an empty list.
So, to clear things up, I'm submitting this patch to update the man
page to indicate that envp is treated like argv.
I generated the below patch from git after pulling the latest. I hope
there is sufficient information in the patch.
Thanks,
Pete
>From c2822b3ba5ef8769eed683e4856247274e016ea5 Mon Sep 17 00:00:00 2001
---
man2/execve.2 | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/man2/execve.2 b/man2/execve.2
index cc91bff..a0b48fc 100644
--- a/man2/execve.2
+++ b/man2/execve.2
@@ -494,10 +494,12 @@ and white spaces in
.I optional-arg
are used to delimit the arguments.
-On Linux,
+On Linux, either
.I argv
+or
+.I envp
can be specified as NULL,
-which has the same effect as specifying this argument
+which has the same effect as specifying these arguments
as a pointer to a list containing a single NULL pointer.
.B "Do not take advantage of this misfeature!"
It is nonstandard and nonportable:
--
1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] execve: Add envp to the Linux notes about NULL pointers
[not found] ` <CAN8Q1EdfNEyYMoMwu95ROZOCLg6t7ncQudqpV5c02n7H-073mA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2013-06-21 12:25 ` Michael Kerrisk
0 siblings, 0 replies; 2+ messages in thread
From: Michael Kerrisk @ 2013-06-21 12:25 UTC (permalink / raw)
To: Peter LaDow
Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w,
linux-man-u79uwXL29TY76Z2rM5mHXA
On 06/13/13 20:37, Peter LaDow wrote:
> This is my first patch submission. I've tried to follow the
> directions found at https://www.kernel.org/doc/man-pages/patches.html,
> but if I've screwed things up, please let me know.
>
> During the review of static analysis results, we discovered a
> functional, but non-portable, use of execve(). For example:
>
> char *cmd[] = { "/path/to/some/file", NULL };
> execve(cmd[0], cmd, NULL);
>
> The call succeeds. Yet, the static analysis tool (rightly) pointed
> out that envp could be dereferenced. But digging into glibc and the
> kernel, it appears that like argv, envp when NULL is treated as if it
> were an empty list.
>
> So, to clear things up, I'm submitting this patch to update the man
> page to indicate that envp is treated like argv.
>
> I generated the below patch from git after pulling the latest. I hope
> there is sufficient information in the patch.
Thanks, Peter. I've applied this patch.
Cheers,
Michael
> ---
> man2/execve.2 | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/man2/execve.2 b/man2/execve.2
> index cc91bff..a0b48fc 100644
> --- a/man2/execve.2
> +++ b/man2/execve.2
> @@ -494,10 +494,12 @@ and white spaces in
> .I optional-arg
> are used to delimit the arguments.
>
> -On Linux,
> +On Linux, either
> .I argv
> +or
> +.I envp
> can be specified as NULL,
> -which has the same effect as specifying this argument
> +which has the same effect as specifying these arguments
> as a pointer to a list containing a single NULL pointer.
> .B "Do not take advantage of this misfeature!"
> It is nonstandard and nonportable:
> --
> 1.8.3.1
>
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-06-21 12:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-13 18:37 [PATCH] execve: Add envp to the Linux notes about NULL pointers Peter LaDow
[not found] ` <CAN8Q1EdfNEyYMoMwu95ROZOCLg6t7ncQudqpV5c02n7H-073mA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-06-21 12:25 ` Michael Kerrisk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).