From: Michael van der Westhuizen Date: Tue, 20 May 2014 13:58:58 +0000 (+0200) Subject: Prevent a stack overflow in fit_check_sign X-Git-Tag: v2014.07-rc3~30 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=64375014c499528d9df5ee37f78844823a9d21f2;p=u-boot Prevent a stack overflow in fit_check_sign It is trivial to crash fit_check_sign by invoking with an absolute path in a deeply nested directory. This is exposed by vboot_test.sh. Signed-off-by: Michael van der Westhuizen Acked-by: Simon Glass --- diff --git a/tools/fit_check_sign.c b/tools/fit_check_sign.c index d6d9340094..817773d48a 100644 --- a/tools/fit_check_sign.c +++ b/tools/fit_check_sign.c @@ -42,12 +42,13 @@ int main(int argc, char **argv) void *fit_blob; char *fdtfile = NULL; char *keyfile = NULL; - char cmdname[50]; + char cmdname[256]; int ret; void *key_blob; int c; - strcpy(cmdname, *argv); + strncpy(cmdname, *argv, sizeof(cmdname) - 1); + cmdname[sizeof(cmdname) - 1] = '\0'; while ((c = getopt(argc, argv, "f:k:")) != -1) switch (c) { case 'f':