1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-08 17:42:12 +03:00

Fix stringop-overflow errors from gcc 10 in iconv.

On s390x, I've recognize various -Werror=stringop-overflow messages
in iconv/loop.c and iconv/skeleton.c if build with gcc10 -O3.

With this commit gcc knows the size and do not raise those errors anymore.
This commit is contained in:
Stefan Liebler
2020-06-16 14:24:20 +02:00
parent 3f4b61a0b8
commit 08538f360f
2 changed files with 13 additions and 9 deletions

View File

@@ -795,11 +795,13 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data,
# else
/* Make sure the remaining bytes fit into the state objects
buffer. */
assert (inend - *inptrp < 4);
size_t cnt_after = inend - *inptrp;
assert (cnt_after <= sizeof (data->__statep->__value.__wchb));
size_t cnt;
for (cnt = 0; *inptrp < inend; ++cnt)
data->__statep->__value.__wchb[cnt] = *(*inptrp)++;
for (cnt = 0; cnt < cnt_after; ++cnt)
data->__statep->__value.__wchb[cnt] = (*inptrp)[cnt];
*inptrp = inend;
data->__statep->__count &= ~7;
data->__statep->__count |= cnt;
# endif