]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
don't segfault when asked for help 1246/head
authorMatthew Newton <mcn4@leicester.ac.uk>
Thu, 17 Sep 2015 23:36:41 +0000 (00:36 +0100)
committerMatthew Newton <mcn4@leicester.ac.uk>
Thu, 17 Sep 2015 23:36:41 +0000 (00:36 +0100)
print the help for the current command if there are no subcommands
to list

src/main/command.c

index 99fa117d950f2e96d2a62bc534d0b36ea2f60812..099bb782596390d28fd8492bdcf50beaf18d3cb6 100644 (file)
@@ -2851,10 +2851,19 @@ static void print_help(rad_listen_t *listener, int argc, char *argv[],
 {
        int i;
 
+       /* this should never happen, but if it does then just return gracefully */
+       if (!table) return;
+
        for (i = 0; table[i].command != NULL; i++) {
                if (argc > 0) {
                        if (strcmp(table[i].command, argv[0]) == 0) {
-                               print_help(listener, argc - 1, argv + 1, table[i].table, recursive);
+                               if (table[i].table) {
+                                       print_help(listener, argc - 1, argv + 1, table[i].table, recursive);
+                               } else {
+                                       if (table[i].help) {
+                                               cprintf(listener, "%s\n", table[i].help);
+                                       }
+                               }
                                return;
                        }