rpmio: fix potential buffer overflow in Fdopen

In file included from /usr/include/string.h:648:0,
                 from ../system.h:76,
                 from rpmio.c:6:
In function 'strncat',
    inlined from 'Fdopen' at rpmio.c:3473:5:
/usr/include/bits/string3.h:158:10: warning: call to __builtin___strncat_chk might overflow destination buffer
   return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
This commit is contained in:
Дмитрий Левин 2017-01-14 13:42:53 +00:00
parent 509272d41b
commit 4ab56b3647

View File

@ -3470,8 +3470,8 @@ fprintf(stderr, "*** Fdopen(%p,%s) %s\n", fd, fmode, fdbg(fd));
if (stdio[0] == '\0') if (stdio[0] == '\0')
return NULL; return NULL;
zstdio[0] = '\0'; zstdio[0] = '\0';
strncat(zstdio, stdio, sizeof(zstdio) - strlen(zstdio)); strncat(zstdio, stdio, sizeof(zstdio) - 1 - strlen(zstdio));
strncat(zstdio, other, sizeof(zstdio) - strlen(zstdio)); strncat(zstdio, other, sizeof(zstdio) - 1 - strlen(zstdio));
if (end == NULL && other[0] == '\0') if (end == NULL && other[0] == '\0')
/*@-refcounttrans -retalias@*/ return fd; /*@=refcounttrans =retalias@*/ /*@-refcounttrans -retalias@*/ return fd; /*@=refcounttrans =retalias@*/