diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2008-04-28 19:10:25 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2008-04-28 19:10:25 +0300 |
commit | b22712816cff6ee572056cb55c5d256a33ae1778 (patch) | |
tree | fe8ad79bf3fd4fa9b97edae6fbfc49ab4c327f07 /lib | |
parent | bbc89fbd350a27e296171f6eb973143662c88214 (diff) | |
download | rpm-b22712816cff6ee572056cb55c5d256a33ae1778.tar.gz rpm-b22712816cff6ee572056cb55c5d256a33ae1778.tar.bz2 rpm-b22712816cff6ee572056cb55c5d256a33ae1778.zip |
Remove alloca() from strntoul() helper in cpio
- only small (< 10 chars) buffers from struct cpioCrcPhysicalHeader are
ever passed in, tmp buffer on stack is safe
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cpio.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/cpio.c b/lib/cpio.c index 79d297ef0..524985ece 100644 --- a/lib/cpio.c +++ b/lib/cpio.c @@ -28,15 +28,12 @@ */ static int strntoul(const char *str,char **endptr, int base, size_t num) { - char * buf, * end; + char buf[num+1], * end; unsigned long ret; - buf = alloca(num + 1); - strncpy(buf, str, num); - buf[num] = '\0'; + rstrlcpy(buf, str, num+1); ret = strtoul(buf, &end, base); -/* LCL: strtoul annotations */ if (*end != '\0') *endptr = ((char *)str) + (end - buf); /* XXX discards const */ else |