]> git.sur5r.net Git - u-boot/commitdiff
Prevent a stack overflow in fit_check_sign
authorMichael van der Westhuizen <michael@smart-africa.com>
Tue, 20 May 2014 13:58:58 +0000 (15:58 +0200)
committerTom Rini <trini@ti.com>
Thu, 5 Jun 2014 18:44:56 +0000 (14:44 -0400)
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 <michael@smart-africa.com>
Acked-by: Simon Glass <sjg@chromium.org>
tools/fit_check_sign.c

index d6d93400949bacfab2678bdc8376520079682367..817773d48a0bbb37934c565835d39e7111e5f059 100644 (file)
@@ -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':