Fix: Unchecked strdup return values in set_option
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 10 Jul 2014 21:04:19 +0000 (17:04 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Fri, 11 Jul 2014 20:01:38 +0000 (16:01 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/main.c

index 4d700d1e54130fae8ae19369e8bdc8e3b7ca7771..548cc43095b633bb09528085dfb878a5e99578f6 100644 (file)
@@ -4199,6 +4199,10 @@ static int set_option(int opt, const char *arg, const char *optname)
                break;
        case 'g':
                tracing_group_name = strdup(arg);
+               if (!tracing_group_name) {
+                       perror("strdup");
+                       ret = -ENOMEM;
+               }
                break;
        case 'h':
                usage();
@@ -4253,22 +4257,42 @@ static int set_option(int opt, const char *arg, const char *optname)
                break;
        case 'u':
                consumerd32_bin = strdup(arg);
+               if (!consumerd32_bin) {
+                       perror("strdup");
+                       ret = -ENOMEM;
+               }
                consumerd32_bin_override = 1;
                break;
        case 'U':
                consumerd32_libdir = strdup(arg);
+               if (!consumerd32_libdir) {
+                       perror("strdup");
+                       ret = -ENOMEM;
+               }
                consumerd32_libdir_override = 1;
                break;
        case 't':
                consumerd64_bin = strdup(arg);
+               if (!consumerd64_bin) {
+                       perror("strdup");
+                       ret = -ENOMEM;
+               }
                consumerd64_bin_override = 1;
                break;
        case 'T':
                consumerd64_libdir = strdup(arg);
+               if (!consumerd64_libdir) {
+                       perror("strdup");
+                       ret = -ENOMEM;
+               }
                consumerd64_libdir_override = 1;
                break;
        case 'p':
                opt_pidfile = strdup(arg);
+               if (!opt_pidfile) {
+                       perror("strdup");
+                       ret = -ENOMEM;
+               }
                break;
        case 'J': /* JUL TCP port. */
        {
@@ -4297,6 +4321,10 @@ static int set_option(int opt, const char *arg, const char *optname)
                break;
        case 'P': /* probe modules list */
                kmod_probes_list = strdup(arg);
+               if (!kmod_probes_list) {
+                       perror("strdup");
+                       ret = -ENOMEM;
+               }
                break;
        case 'f':
                /* This is handled in set_options() thus silent break. */
This page took 0.028728 seconds and 4 git commands to generate.