mirror of
https://github.com/masscollaborationlabs/emacs.git
synced 2025-07-04 19:29:37 +00:00
Avert crash in store_mode_line_string on Android 5.0 and earlier
* src/xdisp.c (store_mode_line_string) [__ANDROID_API__ < 22]: Call strlen on STRING if the limit would otherwise be SIZE_MAX, or if the address of the string is within PRECISION bytes of UINTPTR_MAX, in which case it cannot possibly be larger than PRECISION.
This commit is contained in:
parent
e7c85f9235
commit
8b1841021c
1 changed files with 12 additions and 1 deletions
13
src/xdisp.c
13
src/xdisp.c
|
@ -28053,7 +28053,18 @@ store_mode_line_string (const char *string, Lisp_Object lisp_string,
|
||||||
|
|
||||||
if (string != NULL)
|
if (string != NULL)
|
||||||
{
|
{
|
||||||
len = strnlen (string, precision <= 0 ? SIZE_MAX : precision);
|
#if defined HAVE_ANDROID && !defined ANDROID_STUBIFY \
|
||||||
|
&& __ANDROID_API__ < 22
|
||||||
|
/* Circumvent a bug in memchr preventing strnlen from returning
|
||||||
|
valid values when a large limit is specified.
|
||||||
|
|
||||||
|
https://issuetracker.google.com/issues/37020957 */
|
||||||
|
if (precision <= 0 || ((uintptr_t) string
|
||||||
|
> (UINTPTR_MAX - precision)))
|
||||||
|
len = strlen (string);
|
||||||
|
else
|
||||||
|
#endif /* HAVE_ANDROID && !ANDROID_STUBIFY && __ANDROID_API__ < 22 */
|
||||||
|
len = strnlen (string, precision <= 0 ? SIZE_MAX : precision);
|
||||||
lisp_string = make_string (string, len);
|
lisp_string = make_string (string, len);
|
||||||
if (NILP (props))
|
if (NILP (props))
|
||||||
props = mode_line_string_face_prop;
|
props = mode_line_string_face_prop;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue