From ba923cab0006838eb726e40207501ddf16eabd80 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 12 Jun 2014 07:24:44 -0600 Subject: [PATCH] tools: Check arguments in fit_check_sign/fit_info These tools crash if no arguments are provided. Add checks to avoid this. Signed-off-by: Simon Glass Acked-by: Heiko Schocher --- tools/fit_check_sign.c | 9 +++++++++ tools/fit_info.c | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/tools/fit_check_sign.c b/tools/fit_check_sign.c index af257cc8a2..e1198bca44 100644 --- a/tools/fit_check_sign.c +++ b/tools/fit_check_sign.c @@ -62,6 +62,15 @@ int main(int argc, char **argv) break; } + if (!fdtfile) { + fprintf(stderr, "%s: Missing fdt file\n", *argv); + usage(*argv); + } + if (!keyfile) { + fprintf(stderr, "%s: Missing key file\n", *argv); + usage(*argv); + } + ffd = mmap_fdt(cmdname, fdtfile, 0, &fit_blob, &fsbuf, false); if (ffd < 0) return EXIT_FAILURE; diff --git a/tools/fit_info.c b/tools/fit_info.c index afbed7b599..481ac6dd81 100644 --- a/tools/fit_info.c +++ b/tools/fit_info.c @@ -68,6 +68,18 @@ int main(int argc, char **argv) break; } + if (!fdtfile) { + fprintf(stderr, "%s: Missing fdt file\n", *argv); + usage(*argv); + } + if (!nodename) { + fprintf(stderr, "%s: Missing node name\n", *argv); + usage(*argv); + } + if (!propertyname) { + fprintf(stderr, "%s: Missing property name\n", *argv); + usage(*argv); + } ffd = mmap_fdt(cmdname, fdtfile, 0, &fit_blob, &fsbuf, false); if (ffd < 0) { -- 2.30.2