A patch to fix the segment fault when no sub-command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bug is reported on Redhat Bugzilla, id 1278543.
When use the invalid command like:
# cifscreds -u root
Will get a segment fault.
Add a argument check to avoid the segment fault when no sub-command, and
return with stderr 'Need command'.

diff --git a/cifscreds.c b/cifscreds.c
index 5d84c3c..bb63369 100644
--- a/cifscreds.c
+++ b/cifscreds.c
@@ -488,6 +488,13 @@ int main(int argc, char **argv)
        }

        /* find the best fit command */
+
+        /* check if there is sub-command */
+        if (argv[optind] == NULL) {
+                fprintf(stderr, "Need command\n");
+                return EXIT_FAILURE;
+        }
+
        best = NULL;
        n = strnlen(argv[optind], MAX_COMMAND_SIZE);
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux