From c2f443c82440f2be8815fc0cb4f5ddbd6feb0c8a Mon Sep 17 00:00:00 2001 From: tjr Date: Sat, 29 Jun 2002 04:10:40 +0000 Subject: Check that snprintf() does not truncate the destination pathname when linking into a directory. --- bin/ln/ln.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'bin/ln') 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; } -- cgit v1.1