summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2002-06-29 04:10:40 +0000
committertjr <tjr@FreeBSD.org>2002-06-29 04:10:40 +0000
commitc2f443c82440f2be8815fc0cb4f5ddbd6feb0c8a (patch)
treee3453f4dff6c8722e272b8cb0505b3e50c99d1c2
parent83975c1387e1172a467904adae4a25e50b7dedc8 (diff)
downloadFreeBSD-src-c2f443c82440f2be8815fc0cb4f5ddbd6feb0c8a.zip
FreeBSD-src-c2f443c82440f2be8815fc0cb4f5ddbd6feb0c8a.tar.gz
Check that snprintf() does not truncate the destination pathname when
linking into a directory.
-rw-r--r--bin/ln/ln.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/bin/ln/ln.c b/bin/ln/ln.c
index ccae31d..0b0b46b 100644
--- a/bin/ln/ln.c
+++ b/bin/ln/ln.c
@@ -189,7 +189,12 @@ linkit(const char *target, const char *source, int isdir)
p = target;
else
++p;
- (void)snprintf(path, sizeof(path), "%s/%s", source, p);
+ if (snprintf(path, sizeof(path), "%s/%s", source, p) >=
+ sizeof(path)) {
+ errno = ENAMETOOLONG;
+ warn("%s", target);
+ return (1);
+ }
source = path;
}
OpenPOWER on IntegriCloud