diff options
| author | Po Lu | 2024-07-05 12:09:52 +0800 |
|---|---|---|
| committer | Po Lu | 2024-07-05 12:09:52 +0800 |
| commit | 04d7318efa20cce3aa369fdfd563d8364feb6e78 (patch) | |
| tree | 12bec2e418e7572dc9fba3f927d6ca9ce7c8ce06 /src | |
| parent | 507a13f5a1615d39f31d75547835416b29677c03 (diff) | |
| download | emacs-04d7318efa20cce3aa369fdfd563d8364feb6e78.tar.gz emacs-04d7318efa20cce3aa369fdfd563d8364feb6e78.zip | |
Enable Gnulib substitute on Android systems with defective strnlen
* configure.ac (AC_FUNC_STRNLEN): Detect a bug where strnlen is
liable to integer overflows if addition of the search limit to
the string would also overflow.
* src/xdisp.c (store_mode_line_string): Remove stopgap measure.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 566c4b211d6..8c7e8e5cb43 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -28065,18 +28065,7 @@ store_mode_line_string (const char *string, Lisp_Object lisp_string, | |||
| 28065 | 28065 | ||
| 28066 | if (string != NULL) | 28066 | if (string != NULL) |
| 28067 | { | 28067 | { |
| 28068 | #if defined HAVE_ANDROID && !defined ANDROID_STUBIFY \ | 28068 | len = strnlen (string, precision <= 0 ? SIZE_MAX : precision); |
| 28069 | && __ANDROID_API__ < 22 | ||
| 28070 | /* Circumvent a bug in memchr preventing strnlen from returning | ||
| 28071 | valid values when a large limit is specified. | ||
| 28072 | |||
| 28073 | https://issuetracker.google.com/issues/37020957 */ | ||
| 28074 | if (precision <= 0 || ((uintptr_t) string | ||
| 28075 | > (UINTPTR_MAX - precision))) | ||
| 28076 | len = strlen (string); | ||
| 28077 | else | ||
| 28078 | #endif /* HAVE_ANDROID && !ANDROID_STUBIFY && __ANDROID_API__ < 22 */ | ||
| 28079 | len = strnlen (string, precision <= 0 ? SIZE_MAX : precision); | ||
| 28080 | lisp_string = make_string (string, len); | 28069 | lisp_string = make_string (string, len); |
| 28081 | if (NILP (props)) | 28070 | if (NILP (props)) |
| 28082 | props = mode_line_string_face_prop; | 28071 | props = mode_line_string_face_prop; |