From: Simon Wilkinson Date: Mon, 4 Mar 2013 16:22:08 +0000 (+0000) Subject: upserver: Don't overflow file and hostname buffers X-Git-Tag: upstream/1.8.0_pre1^2~1310 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=d672d5ee78d7673f3c42a7a343989b2bd4dca02b;p=packages%2Fo%2Fopenafs.git upserver: Don't overflow file and hostname buffers If the user specifies a ridiculously long command line, don't overflow the filename or hostname buffers with what they supply. Caught by coverity (#985911) Change-Id: Ia73f9fb94491f5691358eec1d13dbdd2651a604c Reviewed-on: http://gerrit.openafs.org/9546 Reviewed-by: Jeffrey Altman Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/update/client.c b/src/update/client.c index bdcfd521f..c822d3d23 100644 --- a/src/update/client.c +++ b/src/update/client.c @@ -177,10 +177,18 @@ main(int argc, char **argv) ("Usage: upclient [-crypt] [-clear] [-t ] [-verbose]* + [-help]\n"); exit(1); } - } else if (strlen(hostname) == 0) - strcpy(hostname, argv[a]); - else { - strcpy(filename, argv[a]); + } else if (strlen(hostname) == 0) { + if (strlcpy(hostname, argv[a], sizeof(hostname)) + >= sizeof(hostname)) { + fprintf(stderr, "Supplied hostname is too long\n"); + exit(1); + } + } else { + if (strlcpy(filename, argv[a], sizeof(filename)) + >= sizeof(filename)) { + fprintf(stderr, "Supplied filename is too long\n"); + exit(1); + } FilepathNormalize(filename); AddToList(&dirname, filename); }