diff options
author | Daniel Drake <dsd@laptop.org> | 2011-05-15 18:17:37 (GMT) |
---|---|---|
committer | Daniel Drake <dsd@laptop.org> | 2011-05-15 18:17:58 (GMT) |
commit | 0d914934a0b4df62787ef6f1ab094821e5387cd8 (patch) | |
tree | 893fd285b54e1e0c292d48af27303912eac895c9 /bin | |
parent | 05b58cf222219b55023717995987aa691f39980b (diff) |
zhashfs: fix argv corruption
Diffstat (limited to 'bin')
-rw-r--r-- | bin/zhashfs.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/bin/zhashfs.c b/bin/zhashfs.c index b3b86e0..161bb75 100644 --- a/bin/zhashfs.c +++ b/bin/zhashfs.c @@ -82,7 +82,7 @@ int main(int argc, char **argv) int skip; unsigned char *pbuf; // fill pattern buffer - char *pname; // fill pattern file name + char pname[PATH_MAX]; // fill pattern file name FILE *pfile; // fill pattern file int patterned, n; @@ -121,7 +121,10 @@ int main(int argc, char **argv) /* open and read an optional fill pattern file */ pbuf = NULL; - pname = strcat(argv[3], ".fill"); + strncpy(pname, argv[3], sizeof(pname) - 6); + strcat(pname, ".fill"); + pname[sizeof(pname) - 1] = 0; + pfile = fopen(pname, "rb"); if (pfile != NULL) { pbuf = malloc(PATTERN_SIZE); |