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 54f9484236d13fde5a0c1e0f5654c54c707b720c..196a83ea35d42d16480bb7900c8007b8dbfb10c0 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");