mirror of git://git.musl-libc.org/musl
fix unlikely corner cases in getopt's message printing
like fputs (see commit10a17dfbad
), the message printing code for getopt assumed that fwrite only returns 0 on failure, but it can also happen on success if the total length to be written is zero. programs with zero-length argv[0] were affected. commit500c6886c6
introduced this problem in getopt by fixing the fwrite behavior to conform to the requirements of ISO C. previously the wrong expectations of the getopt code were met by the fwrite implementation.
This commit is contained in:
parent
10a17dfbad
commit
ef2b5e9f13
|
@ -17,9 +17,9 @@ void __getopt_msg(const char *a, const char *b, const char *c, size_t l)
|
|||
FILE *f = stderr;
|
||||
b = __lctrans_cur(b);
|
||||
flockfile(f);
|
||||
fwrite(a, strlen(a), 1, f)
|
||||
fputs(a, f)>=0
|
||||
&& fwrite(b, strlen(b), 1, f)
|
||||
&& fwrite(c, l, 1, f)
|
||||
&& fwrite(c, 1, l, f)==l
|
||||
&& putc('\n', f);
|
||||
funlockfile(f);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue