diff options
author | sepotvin <sepotvin@FreeBSD.org> | 2009-09-16 19:53:29 +0000 |
---|---|---|
committer | sepotvin <sepotvin@FreeBSD.org> | 2009-09-16 19:53:29 +0000 |
commit | 14cc0cbfb36e79d131ce85f669f6b7ca17363d1d (patch) | |
tree | b87eac38031fbf477e18cfed856a37597d84a24a /gnu | |
parent | 9695ccf66a382aa5f86833767324228f84e80b6d (diff) | |
download | FreeBSD-src-14cc0cbfb36e79d131ce85f669f6b7ca17363d1d.zip FreeBSD-src-14cc0cbfb36e79d131ce85f669f6b7ca17363d1d.tar.gz |
The buffer returned by fgenln is not a "C" string and might not be NUL
terminated. Make sure that it is before using it.
Reviewed by: marck@
MFC after: 3 days
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/usr.bin/patch/common.h | 1 | ||||
-rw-r--r-- | gnu/usr.bin/patch/pch.c | 3 |
2 files changed, 3 insertions, 1 deletions
diff --git a/gnu/usr.bin/patch/common.h b/gnu/usr.bin/patch/common.h index 7063be6..aa19105 100644 --- a/gnu/usr.bin/patch/common.h +++ b/gnu/usr.bin/patch/common.h @@ -34,6 +34,7 @@ #define Strcpy (void)strcpy #define Strcat (void)strcat #define Strlcpy (void)strlcpy +#define Strncpy (void)strncpy #define Strlcat (void)strlcat /* NeXT declares malloc and realloc incompatibly from us in some of diff --git a/gnu/usr.bin/patch/pch.c b/gnu/usr.bin/patch/pch.c index d72f84f..dba4582 100644 --- a/gnu/usr.bin/patch/pch.c +++ b/gnu/usr.bin/patch/pch.c @@ -1176,7 +1176,8 @@ pgets(bool do_indent) indent++; } } - Strlcpy(buf, line, len + 1 - skipped); + Strncpy(buf, line, len - skipped); + buf[len - skipped] = '\0'; } return len; } |