cli: check against multiple -f invocations to avoid leaks (patch by Stanislav Fomichev)
authorFelix Fietkau <nbd@openwrt.org>
Fri, 21 Oct 2011 13:15:24 +0000 (15:15 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Fri, 21 Oct 2011 13:17:06 +0000 (15:17 +0200)
cli.c

diff --git a/cli.c b/cli.c
index 54f9484..196a83e 100644 (file)
--- a/cli.c
+++ b/cli.c
@@ -633,6 +633,11 @@ int main(int argc, char **argv)
                                delimiter = optarg;
                                break;
                        case 'f':
+                               if (input != stdin) {
+                                       perror("uci");
+                                       return 1;
+                               }
+
                                input = fopen(optarg, "r");
                                if (!input) {
                                        perror("uci");