diff options
author | Stefan Liebler <stli@linux.ibm.com> | 2020-06-16 14:24:20 +0200 |
---|---|---|
committer | Stefan Liebler <stli@linux.ibm.com> | 2020-07-07 09:41:32 +0200 |
commit | 08538f360f14dbe2e3b04a30148e342f248d9de5 (patch) | |
tree | e881e06430ec37cebac7cc2c31334349bbb878d1 /iconv/skeleton.c | |
parent | 3f4b61a0b8de67ef9f20737919c713ddfc4bd620 (diff) | |
download | glibc-08538f360f14dbe2e3b04a30148e342f248d9de5.tar glibc-08538f360f14dbe2e3b04a30148e342f248d9de5.tar.gz glibc-08538f360f14dbe2e3b04a30148e342f248d9de5.tar.bz2 glibc-08538f360f14dbe2e3b04a30148e342f248d9de5.zip |
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.
Diffstat (limited to 'iconv/skeleton.c')
-rw-r--r-- | iconv/skeleton.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/iconv/skeleton.c b/iconv/skeleton.c index 1dc642e2fc..1a38b51a5a 100644 --- a/iconv/skeleton.c +++ b/iconv/skeleton.c @@ -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 |