]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/commit
MFC r305406,r305409,r305412
authorache <ache@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Thu, 8 Sep 2016 05:13:50 +0000 (05:13 +0000)
committerache <ache@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Thu, 8 Sep 2016 05:13:50 +0000 (05:13 +0000)
commit2832ebf2f9eaf764bcc2c16e2f9ed2e61424437e
tree73f2bc0f039911954a4e05204dfd04c1b27395a4
parent9e70cccac8745508f33af4669276aecc26421a75
MFC r305406,r305409,r305412

1) Fix errors handling.

2) Prevent out of bounds access to ws[-1] (passed buffer) which happens
when the first mb sequence is incomplete and there are not enougn chars in
the read buffer. ws[-1] may lead to memory faults or false results, in
case the memory here contains '\n'.

3) Fix n == 1 case. Here should be no physical read (fill buffer) attempt
(we read n - 1 chars with the room for NUL, see fgets()),
and no NULL return.

git-svn-id: svn://svn.freebsd.org/base/stable/10@305577 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
lib/libc/stdio/fgetws.c