vfscanf: Avoid multiple reads of multi-byte character width
commit9dd87afbf1a2f7991a733609bbda6f26cadaa6ce
authorFlorian Weimer <fweimer@redhat.com>
Fri, 2 Sep 2016 13:59:34 +0000 (2 15:59 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Fri, 2 Sep 2016 13:59:34 +0000 (2 15:59 +0200)
tree92f2635fe04cf52d11e3eaf91dab849c7ef1bdba
parent326e288b1e43832c138e5eb4521157d8aacef5b7
vfscanf: Avoid multiple reads of multi-byte character width

This avoids a race condition if the process-global locale is changed
while vfscanf is running.  MB_LEN_MAX is always larger than MB_CUR_MAX,
so we might realloc earlier than necessary (but even MB_CUR_MAX could
be larger than the minimum required space).

The existing length was a bit questionable because str + MB_LEN_MAX
might point past the end of the buffer.
ChangeLog
stdio-common/vfscanf.c