diff options
author | tjr <tjr@FreeBSD.org> | 2002-06-29 04:10:40 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2002-06-29 04:10:40 +0000 |
commit | c2f443c82440f2be8815fc0cb4f5ddbd6feb0c8a (patch) | |
tree | e3453f4dff6c8722e272b8cb0505b3e50c99d1c2 /bin | |
parent | 83975c1387e1172a467904adae4a25e50b7dedc8 (diff) | |
download | FreeBSD-src-c2f443c82440f2be8815fc0cb4f5ddbd6feb0c8a.zip FreeBSD-src-c2f443c82440f2be8815fc0cb4f5ddbd6feb0c8a.tar.gz |
Check that snprintf() does not truncate the destination pathname when
linking into a directory.
Diffstat (limited to 'bin')
-rw-r--r-- | bin/ln/ln.c | 7 |
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; } |