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:
14
iconv/loop.c
14
iconv/loop.c
@@ -420,8 +420,10 @@ SINGLE(LOOPFCT) (struct __gconv_step *step,
|
|||||||
# else
|
# else
|
||||||
/* We don't have enough input for another complete input
|
/* We don't have enough input for another complete input
|
||||||
character. */
|
character. */
|
||||||
while (inptr < inend)
|
size_t inlen_after = inlen + (inend - inptr);
|
||||||
state->__value.__wchb[inlen++] = *inptr++;
|
assert (inlen_after <= sizeof (state->__value.__wchb));
|
||||||
|
for (; inlen < inlen_after; inlen++)
|
||||||
|
state->__value.__wchb[inlen] = *inptr++;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
return __GCONV_INCOMPLETE_INPUT;
|
return __GCONV_INCOMPLETE_INPUT;
|
||||||
@@ -483,11 +485,11 @@ SINGLE(LOOPFCT) (struct __gconv_step *step,
|
|||||||
/* We don't have enough input for another complete input
|
/* We don't have enough input for another complete input
|
||||||
character. */
|
character. */
|
||||||
assert (inend - inptr > (state->__count & ~7));
|
assert (inend - inptr > (state->__count & ~7));
|
||||||
assert (inend - inptr <= sizeof (state->__value));
|
assert (inend - inptr <= sizeof (state->__value.__wchb));
|
||||||
state->__count = (state->__count & ~7) | (inend - inptr);
|
state->__count = (state->__count & ~7) | (inend - inptr);
|
||||||
inlen = 0;
|
for (inlen = 0; inlen < inend - inptr; inlen++)
|
||||||
while (inptr < inend)
|
state->__value.__wchb[inlen] = inptr[inlen];
|
||||||
state->__value.__wchb[inlen++] = *inptr++;
|
inptr = inend;
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -795,11 +795,13 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data,
|
|||||||
# else
|
# else
|
||||||
/* Make sure the remaining bytes fit into the state objects
|
/* Make sure the remaining bytes fit into the state objects
|
||||||
buffer. */
|
buffer. */
|
||||||
assert (inend - *inptrp < 4);
|
size_t cnt_after = inend - *inptrp;
|
||||||
|
assert (cnt_after <= sizeof (data->__statep->__value.__wchb));
|
||||||
|
|
||||||
size_t cnt;
|
size_t cnt;
|
||||||
for (cnt = 0; *inptrp < inend; ++cnt)
|
for (cnt = 0; cnt < cnt_after; ++cnt)
|
||||||
data->__statep->__value.__wchb[cnt] = *(*inptrp)++;
|
data->__statep->__value.__wchb[cnt] = (*inptrp)[cnt];
|
||||||
|
*inptrp = inend;
|
||||||
data->__statep->__count &= ~7;
|
data->__statep->__count &= ~7;
|
||||||
data->__statep->__count |= cnt;
|
data->__statep->__count |= cnt;
|
||||||
# endif
|
# endif
|
||||||
|
Reference in New Issue
Block a user