rpm/fdopen_strncat.diff

23 lines
825 B
Diff
Raw Normal View History

--- ./rpmio/rpmio.c.orig 2012-08-30 16:47:57.000000000 +0000
+++ ./rpmio/rpmio.c 2012-08-30 16:54:01.000000000 +0000
@@ -1370,7 +1370,7 @@ static void cvtfmode (const char *m,
FD_t Fdopen(FD_t ofd, const char *fmode)
{
- char stdio[20], other[20], zstdio[20];
+ char stdio[20], other[20], zstdio[40];
const char *end = NULL;
FDIO_t iof = NULL;
FD_t fd = ofd;
@@ -1385,8 +1385,8 @@ fprintf(stderr, "*** Fdopen(%p,%s) %s\n"
if (stdio[0] == '\0')
return NULL;
zstdio[0] = '\0';
- strncat(zstdio, stdio, sizeof(zstdio) - strlen(zstdio));
- strncat(zstdio, other, sizeof(zstdio) - strlen(zstdio));
+ strncat(zstdio, stdio, sizeof(zstdio) - strlen(zstdio) - 1);
+ strncat(zstdio, other, sizeof(zstdio) - strlen(zstdio) - 1);
if (end == NULL && other[0] == '\0')
return fd;