public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] system.3: Document bug and workaround when the command name starts with a hypen
       [not found] <CA+Tk8fykJjf=KzYjW7YMonnZ1qAdQJhqKDRrX0FNGyAYjSnkqg@mail.gmail.com>
@ 2021-01-04 18:04 ` Alejandro Colomar
  2021-01-04 18:32   ` Alejandro Colomar (man-pages)
                     ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Alejandro Colomar @ 2021-01-04 18:04 UTC (permalink / raw)
  To: mtk.manpages
  Cc: libc-alpha, Alejandro Colomar, linux-man, Ciprian Dorin Craciun,
	Florian Weimer

man-pages bug: 211029
 https://bugzilla.kernel.org/show_bug.cgi?id=211029

Reported-by: Ciprian Dorin Craciun <ciprian.craciun@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---
 man3/system.3 | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/man3/system.3 b/man3/system.3
index aef40417a..0310d9a04 100644
--- a/man3/system.3
+++ b/man3/system.3
@@ -250,6 +250,40 @@ are not executed.
 Such risks are especially grave when using
 .BR system ()
 from a privileged program.
+.SH BUGS
+./" [BUG 211029](https://bugzilla.kernel.org/show_bug.cgi?id=211029)
+./" [Glibc bug](https://sourceware.org/bugzilla/show_bug.cgi?id=27143)
+./" [POSIX bug](https://www.austingroupbugs.net/view.php?id=1440)
+If the command name starts with a hyphen,
+.BR sh (1)
+interprets the command name as an option,
+and the behavior is undefined
+(See the
+.B \-c
+option in
+.BR sh (1).).
+To work around this problem,
+prepend the command with a space as below:
+.PP
+.RS 4
+.EX
+/* system_hyphen.c */
+
+#include <stdlib.h>
+
+int
+main(void)
+{
+    system(" -echo Hello world!");
+    exit(EXIT_SUCCESS);
+}
+.PP
+.RB "$" " sudo ln \-s \-T /usr/bin/echo /usr/bin/\-echo;"
+.RB "$" " cc \-o system_hyphen system_hyphen.c;"
+.RB "$" " ./system_hyphen;"
+Hello world!
+.EE
+.RE
 .SH SEE ALSO
 .BR sh (1),
 .BR execve (2),
-- 
2.29.2


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] system.3: Document bug and workaround when the command name starts with a hypen
  2021-01-04 18:04 ` [PATCH] system.3: Document bug and workaround when the command name starts with a hypen Alejandro Colomar
@ 2021-01-04 18:32   ` Alejandro Colomar (man-pages)
  2021-01-04 20:02     ` Alejandro Colomar (man-pages)
  2021-01-08 14:20   ` [PATCH v3] " Alejandro Colomar
  2021-01-08 14:22   ` [PATCH v4] " Alejandro Colomar
  2 siblings, 1 reply; 10+ messages in thread
From: Alejandro Colomar (man-pages) @ 2021-01-04 18:32 UTC (permalink / raw)
  To: mtk.manpages; +Cc: libc-alpha, linux-man, Ciprian Dorin Craciun, Florian Weimer

Hi Michael,

See a few corrections below.

Cheers,

Alex

On 1/4/21 7:04 PM, Alejandro Colomar wrote:
> man-pages bug: 211029
>  https://bugzilla.kernel.org/show_bug.cgi?id=211029
> 
> Reported-by: Ciprian Dorin Craciun <ciprian.craciun@gmail.com>
> Cc: Florian Weimer <fweimer@redhat.com>
> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
> ---
>  man3/system.3 | 34 ++++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 
> diff --git a/man3/system.3 b/man3/system.3
> index aef40417a..0310d9a04 100644
> --- a/man3/system.3
> +++ b/man3/system.3
> @@ -250,6 +250,40 @@ are not executed.
>  Such risks are especially grave when using
>  .BR system ()
>  from a privileged program.
> +.SH BUGS
> +./" [BUG 211029](https://bugzilla.kernel.org/show_bug.cgi?id=211029)
> +./" [Glibc bug](https://sourceware.org/bugzilla/show_bug.cgi?id=27143)
> +./" [POSIX bug](https://www.austingroupbugs.net/view.php?id=1440)
> +If the command name starts with a hyphen,
> +.BR sh (1)
> +interprets the command name as an option,
> +and the behavior is undefined
> +(See the
> +.B \-c
> +option in

option to

> +.BR sh (1).).
> +To work around this problem,
> +prepend the command with a space as below:
> +.PP
> +.RS 4
> +.EX
> +/* system_hyphen.c */
> +
> +#include <stdlib.h>
> +
> +int
> +main(void)
> +{
> +    system(" -echo Hello world!");

\-echo

> +    exit(EXIT_SUCCESS);
> +}
> +.PP
> +.RB "$" " sudo ln \-s \-T /usr/bin/echo /usr/bin/\-echo;"
> +.RB "$" " cc \-o system_hyphen system_hyphen.c;"
> +.RB "$" " ./system_hyphen;"
> +Hello world!
> +.EE
> +.RE
>  .SH SEE ALSO
>  .BR sh (1),
>  .BR execve (2),
> 

-- 
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] system.3: Document bug and workaround when the command name starts with a hypen
  2021-01-04 18:32   ` Alejandro Colomar (man-pages)
@ 2021-01-04 20:02     ` Alejandro Colomar (man-pages)
  0 siblings, 0 replies; 10+ messages in thread
From: Alejandro Colomar (man-pages) @ 2021-01-04 20:02 UTC (permalink / raw)
  To: mtk.manpages; +Cc: libc-alpha, linux-man, Ciprian Dorin Craciun, Florian Weimer

D'oh

On 1/4/21 7:32 PM, Alejandro Colomar (man-pages) wrote:
> Hi Michael,
> 
> See a few corrections below.
> 
> Cheers,
> 
> Alex
> 
> On 1/4/21 7:04 PM, Alejandro Colomar wrote:
>> man-pages bug: 211029
>>  https://bugzilla.kernel.org/show_bug.cgi?id=211029
>>
>> Reported-by: Ciprian Dorin Craciun <ciprian.craciun@gmail.com>
>> Cc: Florian Weimer <fweimer@redhat.com>
>> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
>> ---
>>  man3/system.3 | 34 ++++++++++++++++++++++++++++++++++
>>  1 file changed, 34 insertions(+)
>>
>> diff --git a/man3/system.3 b/man3/system.3
>> index aef40417a..0310d9a04 100644
>> --- a/man3/system.3
>> +++ b/man3/system.3
>> @@ -250,6 +250,40 @@ are not executed.
>>  Such risks are especially grave when using
>>  .BR system ()
>>  from a privileged program.
>> +.SH BUGS
>> +./" [BUG 211029](https://bugzilla.kernel.org/show_bug.cgi?id=211029)
>> +./" [Glibc bug](https://sourceware.org/bugzilla/show_bug.cgi?id=27143)
>> +./" [POSIX bug](https://www.austingroupbugs.net/view.php?id=1440)

s%/%\\%

>> +If the command name starts with a hyphen,
>> +.BR sh (1)
>> +interprets the command name as an option,
>> +and the behavior is undefined
>> +(See the
>> +.B \-c
>> +option in
> 
> option to
> 
>> +.BR sh (1).).
>> +To work around this problem,
>> +prepend the command with a space as below:
>> +.PP
>> +.RS 4
>> +.EX
>> +/* system_hyphen.c */
>> +
>> +#include <stdlib.h>
>> +
>> +int
>> +main(void)
>> +{
>> +    system(" -echo Hello world!");
> 
> \-echo
> 
>> +    exit(EXIT_SUCCESS);
>> +}
>> +.PP
>> +.RB "$" " sudo ln \-s \-T /usr/bin/echo /usr/bin/\-echo;"
>> +.RB "$" " cc \-o system_hyphen system_hyphen.c;"
>> +.RB "$" " ./system_hyphen;"
>> +Hello world!
>> +.EE
>> +.RE
>>  .SH SEE ALSO
>>  .BR sh (1),
>>  .BR execve (2),
>>
> 

-- 
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v3] system.3: Document bug and workaround when the command name starts with a hypen
  2021-01-04 18:04 ` [PATCH] system.3: Document bug and workaround when the command name starts with a hypen Alejandro Colomar
  2021-01-04 18:32   ` Alejandro Colomar (man-pages)
@ 2021-01-08 14:20   ` Alejandro Colomar
  2021-01-08 14:22   ` [PATCH v4] " Alejandro Colomar
  2 siblings, 0 replies; 10+ messages in thread
From: Alejandro Colomar @ 2021-01-08 14:20 UTC (permalink / raw)
  To: mtk.manpages
  Cc: libc-alpha, Alejandro Colomar, linux-man, Ciprian Dorin Craciun,
	Florian Weimer

man-pages bug: 211029
 https://bugzilla.kernel.org/show_bug.cgi?id=211029

Complete workaround
(it was too long for the page, but it may be useful here):

......

$ sudo ln -s -T /usr/bin/echo /usr/bin/-echo;
$ cc -o system_hyphen -x c - ;

int
main(void)
{
    system(" -echo Hello world!");
    exit(EXIT_SUCCESS);
}

$ ./system_hyphen;
Hello world!

Reported-by: Ciprian Dorin Craciun <ciprian.craciun@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---

Hi Michael,

I forgot to remove some escapings in the commit message in v2.
I hope it arrives in time :)

Cheers,

Alex

 man3/system.3 | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/man3/system.3 b/man3/system.3
index 753d46f7d..ead35ab30 100644
--- a/man3/system.3
+++ b/man3/system.3
@@ -255,6 +255,26 @@ are not executed.
 Such risks are especially grave when using
 .BR system ()
 from a privileged program.
+.SH BUGS
+.\" [BUG 211029](https://bugzilla.kernel.org/show_bug.cgi?id=211029)
+.\" [Glibc bug](https://sourceware.org/bugzilla/show_bug.cgi?id=27143)
+.\" [POSIX bug](https://www.austingroupbugs.net/view.php?id=1440)
+If the command name starts with a hyphen,
+.BR sh (1)
+interprets the command name as an option,
+and the behavior is undefined.
+(See the
+.B \-c
+option to
+.BR sh (1).)
+To work around this problem,
+prepend the command with a space as in the following call:
+.PP
+.RS 4
+.EX
+    system(" \-unfortunate\-command\-name");
+.EE
+.RE
 .SH SEE ALSO
 .BR sh (1),
 .BR execve (2),
-- 
2.29.2


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v4] system.3: Document bug and workaround when the command name starts with a hypen
  2021-01-04 18:04 ` [PATCH] system.3: Document bug and workaround when the command name starts with a hypen Alejandro Colomar
  2021-01-04 18:32   ` Alejandro Colomar (man-pages)
  2021-01-08 14:20   ` [PATCH v3] " Alejandro Colomar
@ 2021-01-08 14:22   ` Alejandro Colomar
  2021-01-08 14:28     ` Alejandro Colomar (man-pages)
  2021-01-18 15:35     ` Michael Kerrisk (man-pages)
  2 siblings, 2 replies; 10+ messages in thread
From: Alejandro Colomar @ 2021-01-08 14:22 UTC (permalink / raw)
  To: mtk.manpages
  Cc: libc-alpha, Alejandro Colomar, linux-man, Ciprian Dorin Craciun,
	Florian Weimer

man-pages bug: 211029
 https://bugzilla.kernel.org/show_bug.cgi?id=211029

Complete workaround
(it was too long for the page, but it may be useful here):

......

$ sudo ln -s -T /usr/bin/echo /usr/bin/-echo;
$ cc -o system_hyphen -x c - ;
#include <stdlib.h>

int
main(void)
{
    system(" -echo Hello world!");
    exit(EXIT_SUCCESS);
}

$ ./system_hyphen;
Hello world!

Reported-by: Ciprian Dorin Craciun <ciprian.craciun@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---

D'oh!

 man3/system.3 | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/man3/system.3 b/man3/system.3
index 753d46f7d..ead35ab30 100644
--- a/man3/system.3
+++ b/man3/system.3
@@ -255,6 +255,26 @@ are not executed.
 Such risks are especially grave when using
 .BR system ()
 from a privileged program.
+.SH BUGS
+.\" [BUG 211029](https://bugzilla.kernel.org/show_bug.cgi?id=211029)
+.\" [Glibc bug](https://sourceware.org/bugzilla/show_bug.cgi?id=27143)
+.\" [POSIX bug](https://www.austingroupbugs.net/view.php?id=1440)
+If the command name starts with a hyphen,
+.BR sh (1)
+interprets the command name as an option,
+and the behavior is undefined.
+(See the
+.B \-c
+option to
+.BR sh (1).)
+To work around this problem,
+prepend the command with a space as in the following call:
+.PP
+.RS 4
+.EX
+    system(" \-unfortunate\-command\-name");
+.EE
+.RE
 .SH SEE ALSO
 .BR sh (1),
 .BR execve (2),
-- 
2.29.2


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v4] system.3: Document bug and workaround when the command name starts with a hypen
  2021-01-08 14:22   ` [PATCH v4] " Alejandro Colomar
@ 2021-01-08 14:28     ` Alejandro Colomar (man-pages)
  2021-01-18 15:28       ` Ping: " Alejandro Colomar (man-pages)
  2021-01-18 15:36       ` Michael Kerrisk (man-pages)
  2021-01-18 15:35     ` Michael Kerrisk (man-pages)
  1 sibling, 2 replies; 10+ messages in thread
From: Alejandro Colomar (man-pages) @ 2021-01-08 14:28 UTC (permalink / raw)
  To: mtk.manpages; +Cc: libc-alpha, linux-man, Ciprian Dorin Craciun, Florian Weimer



On 1/8/21 3:22 PM, Alejandro Colomar wrote:
> man-pages bug: 211029
>  https://bugzilla.kernel.org/show_bug.cgi?id=211029
> 
> Complete workaround

Maybe a bit more readable:
Complete workaround example


> (it was too long for the page, but it may be useful here):
> 
> ......
> 
> $ sudo ln -s -T /usr/bin/echo /usr/bin/-echo;
> $ cc -o system_hyphen -x c - ;
> #include <stdlib.h>
> 
> int
> main(void)
> {
>     system(" -echo Hello world!");
>     exit(EXIT_SUCCESS);
> }
> 
> $ ./system_hyphen;
> Hello world!
> 
> Reported-by: Ciprian Dorin Craciun <ciprian.craciun@gmail.com>
> Cc: Florian Weimer <fweimer@redhat.com>
> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
> ---
> 
> D'oh!
> 
>  man3/system.3 | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/man3/system.3 b/man3/system.3
> index 753d46f7d..ead35ab30 100644
> --- a/man3/system.3
> +++ b/man3/system.3
> @@ -255,6 +255,26 @@ are not executed.
>  Such risks are especially grave when using
>  .BR system ()
>  from a privileged program.
> +.SH BUGS
> +.\" [BUG 211029](https://bugzilla.kernel.org/show_bug.cgi?id=211029)
> +.\" [Glibc bug](https://sourceware.org/bugzilla/show_bug.cgi?id=27143)
> +.\" [POSIX bug](https://www.austingroupbugs.net/view.php?id=1440)
> +If the command name starts with a hyphen,
> +.BR sh (1)
> +interprets the command name as an option,
> +and the behavior is undefined.
> +(See the
> +.B \-c
> +option to
> +.BR sh (1).)
> +To work around this problem,
> +prepend the command with a space as in the following call:
> +.PP
> +.RS 4
> +.EX
> +    system(" \-unfortunate\-command\-name");
> +.EE
> +.RE
>  .SH SEE ALSO
>  .BR sh (1),
>  .BR execve (2),
> 

-- 
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Ping: [PATCH v4] system.3: Document bug and workaround when the command name starts with a hypen
  2021-01-08 14:28     ` Alejandro Colomar (man-pages)
@ 2021-01-18 15:28       ` Alejandro Colomar (man-pages)
  2021-01-18 15:37         ` Michael Kerrisk (man-pages)
  2021-01-18 15:36       ` Michael Kerrisk (man-pages)
  1 sibling, 1 reply; 10+ messages in thread
From: Alejandro Colomar (man-pages) @ 2021-01-18 15:28 UTC (permalink / raw)
  To: mtk.manpages; +Cc: libc-alpha, linux-man, Ciprian Dorin Craciun, Florian Weimer

Hi Michael,

Ping!

And now I noticed a typo in the subject:
s/hypen/hyphen/

Thanks,

Alex

On 1/8/21 3:28 PM, Alejandro Colomar (man-pages) wrote:
> 
> 
> On 1/8/21 3:22 PM, Alejandro Colomar wrote:
>> man-pages bug: 211029
>>  https://bugzilla.kernel.org/show_bug.cgi?id=211029
>>
>> Complete workaround
> 
> Maybe a bit more readable:
> Complete workaround example
> 
> 
>> (it was too long for the page, but it may be useful here):
>>
>> ......
>>
>> $ sudo ln -s -T /usr/bin/echo /usr/bin/-echo;
>> $ cc -o system_hyphen -x c - ;
>> #include <stdlib.h>
>>
>> int
>> main(void)
>> {
>>     system(" -echo Hello world!");
>>     exit(EXIT_SUCCESS);
>> }
>>
>> $ ./system_hyphen;
>> Hello world!
>>
>> Reported-by: Ciprian Dorin Craciun <ciprian.craciun@gmail.com>
>> Cc: Florian Weimer <fweimer@redhat.com>
>> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
>> ---
>>
>> D'oh!
>>
>>  man3/system.3 | 20 ++++++++++++++++++++
>>  1 file changed, 20 insertions(+)
>>
>> diff --git a/man3/system.3 b/man3/system.3
>> index 753d46f7d..ead35ab30 100644
>> --- a/man3/system.3
>> +++ b/man3/system.3
>> @@ -255,6 +255,26 @@ are not executed.
>>  Such risks are especially grave when using
>>  .BR system ()
>>  from a privileged program.
>> +.SH BUGS
>> +.\" [BUG 211029](https://bugzilla.kernel.org/show_bug.cgi?id=211029)
>> +.\" [Glibc bug](https://sourceware.org/bugzilla/show_bug.cgi?id=27143)
>> +.\" [POSIX bug](https://www.austingroupbugs.net/view.php?id=1440)
>> +If the command name starts with a hyphen,
>> +.BR sh (1)
>> +interprets the command name as an option,
>> +and the behavior is undefined.
>> +(See the
>> +.B \-c
>> +option to
>> +.BR sh (1).)
>> +To work around this problem,
>> +prepend the command with a space as in the following call:
>> +.PP
>> +.RS 4
>> +.EX
>> +    system(" \-unfortunate\-command\-name");
>> +.EE
>> +.RE
>>  .SH SEE ALSO
>>  .BR sh (1),
>>  .BR execve (2),
>>
> 


-- 
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v4] system.3: Document bug and workaround when the command name starts with a hypen
  2021-01-08 14:22   ` [PATCH v4] " Alejandro Colomar
  2021-01-08 14:28     ` Alejandro Colomar (man-pages)
@ 2021-01-18 15:35     ` Michael Kerrisk (man-pages)
  1 sibling, 0 replies; 10+ messages in thread
From: Michael Kerrisk (man-pages) @ 2021-01-18 15:35 UTC (permalink / raw)
  To: Alejandro Colomar
  Cc: mtk.manpages, libc-alpha, linux-man, Ciprian Dorin Craciun,
	Florian Weimer

Hi Alex,

On 1/8/21 3:22 PM, Alejandro Colomar wrote:
> man-pages bug: 211029
>  https://bugzilla.kernel.org/show_bug.cgi?id=211029
> 
> Complete workaround
> (it was too long for the page, but it may be useful here):
> 
> ......
> 
> $ sudo ln -s -T /usr/bin/echo /usr/bin/-echo;
> $ cc -o system_hyphen -x c - ;
> #include <stdlib.h>
> 
> int
> main(void)
> {
>     system(" -echo Hello world!");
>     exit(EXIT_SUCCESS);
> }
> 
> $ ./system_hyphen;
> Hello world!
> 
> Reported-by: Ciprian Dorin Craciun <ciprian.craciun@gmail.com>
> Cc: Florian Weimer <fweimer@redhat.com>
> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>

Thanks for the ping. Patch applied, but see man-pages(7)
and my small fix-up in the next commit.

Cheers,

Michael

> ---
> 
> D'oh!
> 
>  man3/system.3 | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/man3/system.3 b/man3/system.3
> index 753d46f7d..ead35ab30 100644
> --- a/man3/system.3
> +++ b/man3/system.3
> @@ -255,6 +255,26 @@ are not executed.
>  Such risks are especially grave when using
>  .BR system ()
>  from a privileged program.
> +.SH BUGS
> +.\" [BUG 211029](https://bugzilla.kernel.org/show_bug.cgi?id=211029)
> +.\" [Glibc bug](https://sourceware.org/bugzilla/show_bug.cgi?id=27143)
> +.\" [POSIX bug](https://www.austingroupbugs.net/view.php?id=1440)
> +If the command name starts with a hyphen,
> +.BR sh (1)
> +interprets the command name as an option,
> +and the behavior is undefined.
> +(See the
> +.B \-c
> +option to
> +.BR sh (1).)
> +To work around this problem,
> +prepend the command with a space as in the following call:
> +.PP
> +.RS 4
> +.EX
> +    system(" \-unfortunate\-command\-name");
> +.EE
> +.RE
>  .SH SEE ALSO
>  .BR sh (1),
>  .BR execve (2),
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v4] system.3: Document bug and workaround when the command name starts with a hypen
  2021-01-08 14:28     ` Alejandro Colomar (man-pages)
  2021-01-18 15:28       ` Ping: " Alejandro Colomar (man-pages)
@ 2021-01-18 15:36       ` Michael Kerrisk (man-pages)
  1 sibling, 0 replies; 10+ messages in thread
From: Michael Kerrisk (man-pages) @ 2021-01-18 15:36 UTC (permalink / raw)
  To: Alejandro Colomar (man-pages)
  Cc: mtk.manpages, libc-alpha, linux-man, Ciprian Dorin Craciun,
	Florian Weimer

On 1/8/21 3:28 PM, Alejandro Colomar (man-pages) wrote:
> 
> 
> On 1/8/21 3:22 PM, Alejandro Colomar wrote:
>> man-pages bug: 211029
>>  https://bugzilla.kernel.org/show_bug.cgi?id=211029
>>
>> Complete workaround
> 
> Maybe a bit more readable:
> Complete workaround example

Changed.

Thanks,

Michael

> 
> 
>> (it was too long for the page, but it may be useful here):
>>
>> ......
>>
>> $ sudo ln -s -T /usr/bin/echo /usr/bin/-echo;
>> $ cc -o system_hyphen -x c - ;
>> #include <stdlib.h>
>>
>> int
>> main(void)
>> {
>>     system(" -echo Hello world!");
>>     exit(EXIT_SUCCESS);
>> }
>>
>> $ ./system_hyphen;
>> Hello world!
>>
>> Reported-by: Ciprian Dorin Craciun <ciprian.craciun@gmail.com>
>> Cc: Florian Weimer <fweimer@redhat.com>
>> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
>> ---
>>
>> D'oh!
>>
>>  man3/system.3 | 20 ++++++++++++++++++++
>>  1 file changed, 20 insertions(+)
>>
>> diff --git a/man3/system.3 b/man3/system.3
>> index 753d46f7d..ead35ab30 100644
>> --- a/man3/system.3
>> +++ b/man3/system.3
>> @@ -255,6 +255,26 @@ are not executed.
>>  Such risks are especially grave when using
>>  .BR system ()
>>  from a privileged program.
>> +.SH BUGS
>> +.\" [BUG 211029](https://bugzilla.kernel.org/show_bug.cgi?id=211029)
>> +.\" [Glibc bug](https://sourceware.org/bugzilla/show_bug.cgi?id=27143)
>> +.\" [POSIX bug](https://www.austingroupbugs.net/view.php?id=1440)
>> +If the command name starts with a hyphen,
>> +.BR sh (1)
>> +interprets the command name as an option,
>> +and the behavior is undefined.
>> +(See the
>> +.B \-c
>> +option to
>> +.BR sh (1).)
>> +To work around this problem,
>> +prepend the command with a space as in the following call:
>> +.PP
>> +.RS 4
>> +.EX
>> +    system(" \-unfortunate\-command\-name");
>> +.EE
>> +.RE
>>  .SH SEE ALSO
>>  .BR sh (1),
>>  .BR execve (2),
>>
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Ping: [PATCH v4] system.3: Document bug and workaround when the command name starts with a hypen
  2021-01-18 15:28       ` Ping: " Alejandro Colomar (man-pages)
@ 2021-01-18 15:37         ` Michael Kerrisk (man-pages)
  0 siblings, 0 replies; 10+ messages in thread
From: Michael Kerrisk (man-pages) @ 2021-01-18 15:37 UTC (permalink / raw)
  To: Alejandro Colomar (man-pages)
  Cc: mtk.manpages, libc-alpha, linux-man, Ciprian Dorin Craciun,
	Florian Weimer

On 1/18/21 4:28 PM, Alejandro Colomar (man-pages) wrote:
> Hi Michael,
> 
> Ping!
> 
> And now I noticed a typo in the subject:
> s/hypen/hyphen/

D'oh! I missed that.

In cases like these, where there's already two amendments to the patch,
perhaps better is a new complete patch, rather than a ping :-).

Thanks,

Michael


> On 1/8/21 3:28 PM, Alejandro Colomar (man-pages) wrote:
>>
>>
>> On 1/8/21 3:22 PM, Alejandro Colomar wrote:
>>> man-pages bug: 211029
>>>  https://bugzilla.kernel.org/show_bug.cgi?id=211029
>>>
>>> Complete workaround
>>
>> Maybe a bit more readable:
>> Complete workaround example
>>
>>
>>> (it was too long for the page, but it may be useful here):
>>>
>>> ......
>>>
>>> $ sudo ln -s -T /usr/bin/echo /usr/bin/-echo;
>>> $ cc -o system_hyphen -x c - ;
>>> #include <stdlib.h>
>>>
>>> int
>>> main(void)
>>> {
>>>     system(" -echo Hello world!");
>>>     exit(EXIT_SUCCESS);
>>> }
>>>
>>> $ ./system_hyphen;
>>> Hello world!
>>>
>>> Reported-by: Ciprian Dorin Craciun <ciprian.craciun@gmail.com>
>>> Cc: Florian Weimer <fweimer@redhat.com>
>>> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
>>> ---
>>>
>>> D'oh!
>>>
>>>  man3/system.3 | 20 ++++++++++++++++++++
>>>  1 file changed, 20 insertions(+)
>>>
>>> diff --git a/man3/system.3 b/man3/system.3
>>> index 753d46f7d..ead35ab30 100644
>>> --- a/man3/system.3
>>> +++ b/man3/system.3
>>> @@ -255,6 +255,26 @@ are not executed.
>>>  Such risks are especially grave when using
>>>  .BR system ()
>>>  from a privileged program.
>>> +.SH BUGS
>>> +.\" [BUG 211029](https://bugzilla.kernel.org/show_bug.cgi?id=211029)
>>> +.\" [Glibc bug](https://sourceware.org/bugzilla/show_bug.cgi?id=27143)
>>> +.\" [POSIX bug](https://www.austingroupbugs.net/view.php?id=1440)
>>> +If the command name starts with a hyphen,
>>> +.BR sh (1)
>>> +interprets the command name as an option,
>>> +and the behavior is undefined.
>>> +(See the
>>> +.B \-c
>>> +option to
>>> +.BR sh (1).)
>>> +To work around this problem,
>>> +prepend the command with a space as in the following call:
>>> +.PP
>>> +.RS 4
>>> +.EX
>>> +    system(" \-unfortunate\-command\-name");
>>> +.EE
>>> +.RE
>>>  .SH SEE ALSO
>>>  .BR sh (1),
>>>  .BR execve (2),
>>>
>>
> 
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-01-18 15:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CA+Tk8fykJjf=KzYjW7YMonnZ1qAdQJhqKDRrX0FNGyAYjSnkqg@mail.gmail.com>
2021-01-04 18:04 ` [PATCH] system.3: Document bug and workaround when the command name starts with a hypen Alejandro Colomar
2021-01-04 18:32   ` Alejandro Colomar (man-pages)
2021-01-04 20:02     ` Alejandro Colomar (man-pages)
2021-01-08 14:20   ` [PATCH v3] " Alejandro Colomar
2021-01-08 14:22   ` [PATCH v4] " Alejandro Colomar
2021-01-08 14:28     ` Alejandro Colomar (man-pages)
2021-01-18 15:28       ` Ping: " Alejandro Colomar (man-pages)
2021-01-18 15:37         ` Michael Kerrisk (man-pages)
2021-01-18 15:36       ` Michael Kerrisk (man-pages)
2021-01-18 15:35     ` Michael Kerrisk (man-pages)

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 read-only IMAP folder(s) and NNTP newsgroup(s).