Bug 23711 - wcsrtombs calls wcsnlen on input data which is not an array
Summary: wcsrtombs calls wcsnlen on input data which is not an array
Status: WAITING
Alias: None
Product: glibc
Classification: Unclassified
Component: locale (show other bugs)
Version: 2.27
: P2 normal
Target Milestone: ---
Assignee: Florian Weimer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-25 13:14 UTC by Florian Weimer
Modified: 2019-11-28 10:03 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Weimer 2018-09-25 13:14:58 UTC
If the destination pointer is not null, __wcsrtombs does this:

      /* This code is based on the safe assumption that all internal
	 multi-byte encodings use the NUL byte only to mark the end
	 of the string.  */
      const wchar_t *srcend = *src + __wcsnlen (*src, len) + 1;

This is invalid because len can be much larger than the actual input data, and calling __wcsnlen this way violates the precondition of the wcsnlen function: the input must be an array.
Comment 1 Florian Weimer 2019-10-30 10:37:19 UTC
Patch posted: https://gnutoolchain-gerrit.osci.io/r/c/glibc/+/445
Comment 2 Florian Weimer 2019-11-28 10:03:35 UTC
This use of wcsnlen appears to be a GNU extension.