summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorrobert <robert@FreeBSD.org>2002-05-23 14:21:02 +0000
committerrobert <robert@FreeBSD.org>2002-05-23 14:21:02 +0000
commit6131a2e28ec6f8852fbd77dd87575ea9950af974 (patch)
tree0ed7fada3c34a8ff733f955a82139978d839193c /lib
parent2354de18fe2b773b0bc300d9f503f5ad5c09153d (diff)
downloadFreeBSD-src-6131a2e28ec6f8852fbd77dd87575ea9950af974.zip
FreeBSD-src-6131a2e28ec6f8852fbd77dd87575ea9950af974.tar.gz
Avoid wandering over the beginning of the actual buffer
if the passed template string contains only 'X' characters. Submitted by: Mark Andrews <marka@isc.org> (patch modified) PR: 38402
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/stdio/mktemp.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libc/stdio/mktemp.c b/lib/libc/stdio/mktemp.c
index 826f2bc..49ba17d 100644
--- a/lib/libc/stdio/mktemp.c
+++ b/lib/libc/stdio/mktemp.c
@@ -128,7 +128,7 @@ _gettemp(path, doopen, domkdir, slen)
}
/* Fill space with random characters */
- while (*trv == 'X') {
+ while (trv >= path && *trv == 'X') {
rand = arc4random() % (sizeof(padchar) - 1);
*trv-- = padchar[rand];
}
OpenPOWER on IntegriCloud