On mips, arc, powerpc, and s390 gcc 14 triggers the warning
In function ‘charmap_new_char’,
inlined from ‘parse_charmap.isra’ at ../locale/programs/charmap.c:570:6:
../locale/programs/charmap.c:1017:32: error: ‘strncmp’ specified bound [
2147483649,
4294967295] exceeds maximum object size
2147483647 [-Werror=stringop-overread]
1017 | if (cp == &from[len1 - 1] || strncmp (from, to, prefix_len) != 0)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../locale/programs/charmap.c:1017:32: error: ‘strncmp’ specified bound [
2147483649,
4294967295] exceeds maximum object size
2147483647 [-Werror=stringop-overread]
cc1: all warnings being treated as errors
So move the case to an special function and disable the sanitizer.
prefix_len = (cp - from) + 1;
- if (cp == &from[len1 - 1] || strncmp (from, to, prefix_len) != 0)
+ if (check_illegal_range (cp, from, len1, to, prefix_len))
goto illegal_range;
errno = 0;
unsigned char bytes[];
};
+static inline bool
+__attribute_disable_ubsan__
+check_illegal_range (const char *cp, const char *from, size_t len1,
+ const char *to, size_t prefix_len)
+{
+ return cp == &from[len1 - 1] || strncmp (from, to, prefix_len) != 0;
+}
/* True if the encoding is not ASCII compatible. */
extern bool enc_not_ascii_compatible;
prefix_len = (cp - from) + 1;
- if (cp == &from[len1 - 1] || strncmp (from, to, prefix_len) != 0)
+ if (check_illegal_range (cp, from, len1, to, prefix_len))
goto invalid_range;
errno = 0;