Skip to content
  • Victor Toso's avatar
    covscan: initialize argv's copy · cedab5fe
    Victor Toso authored
    
    
    Otherwise we get a CLANG_WARNING due accessing garbage.
    
    Covscan report:
     > spice-vdagent-0.19.0/src/vdagent/vdagent.c:471:9: warning: 1st function call argument is an uninitialized value
     > #        execvp(orig_argv[0], orig_argv);
     > #        ^      ~~~~~~~~~~~~
     > spice-vdagent-0.19.0/src/vdagent/vdagent.c:421:24: note: Storing uninitialized value
     > #    char **orig_argv = g_memdup(argv, sizeof(char*) * (argc+1));
     > #                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     > spice-vdagent-0.19.0/src/vdagent/vdagent.c:434:9: note: Assuming 'error' is equal to NULL
     > #    if (error != NULL) {
     > #        ^~~~~~~~~~~~~
     > spice-vdagent-0.19.0/src/vdagent/vdagent.c:434:5: note: Taking false branch
     > #    if (error != NULL) {
     > #    ^
     > spice-vdagent-0.19.0/src/vdagent/vdagent.c:442:9: note: Assuming 'portdev' is not equal to NULL
     > #    if (portdev == NULL)
     > #        ^~~~~~~~~~~~~~~
     > spice-vdagent-0.19.0/src/vdagent/vdagent.c:442:5: note: Taking false branch
     > #    if (portdev == NULL)
     > #    ^
     > spice-vdagent-0.19.0/src/vdagent/vdagent.c:445:9: note: Assuming 'vdagentd_socket' is not equal to NULL
     > #    if (vdagentd_socket == NULL)
     > #        ^~~~~~~~~~~~~~~~~~~~~~~
     > spice-vdagent-0.19.0/src/vdagent/vdagent.c:445:5: note: Taking false branch
     > #    if (vdagentd_socket == NULL)
     > #    ^
     > spice-vdagent-0.19.0/src/vdagent/vdagent.c:448:30: note: Assuming 'do_daemonize' is 0
     > #    openlog("spice-vdagent", do_daemonize ? LOG_PID : (LOG_PID | LOG_PERROR),
     > #                             ^~~~~~~~~~~~
     > spice-vdagent-0.19.0/src/vdagent/vdagent.c:448:30: note: '?' condition is false
     > spice-vdagent-0.19.0/src/vdagent/vdagent.c:451:9: note: Assuming the condition is false
     > #    if (!g_file_test(portdev, G_FILE_TEST_EXISTS)) {
     > #        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     > spice-vdagent-0.19.0/src/vdagent/vdagent.c:451:5: note: Taking false branch
     > #    if (!g_file_test(portdev, G_FILE_TEST_EXISTS)) {
     > #    ^
     > spice-vdagent-0.19.0/src/vdagent/vdagent.c:457:9: note: Assuming 'do_daemonize' is 0
     > #    if (do_daemonize)
     > #        ^~~~~~~~~~~~
     > spice-vdagent-0.19.0/src/vdagent/vdagent.c:457:5: note: Taking false branch
     > #    if (do_daemonize)
     > #    ^
     > spice-vdagent-0.19.0/src/vdagent/vdagent.c:468:9: note: Assuming 'version_mismatch' is not equal to 0
     > #    if (version_mismatch) {
     > #        ^~~~~~~~~~~~~~~~
     > spice-vdagent-0.19.0/src/vdagent/vdagent.c:468:5: note: Taking true branch
     > #    if (version_mismatch) {
     > #    ^
     > spice-vdagent-0.19.0/src/vdagent/vdagent.c:471:9: note: 1st function call argument is an uninitialized value
     > #        execvp(orig_argv[0], orig_argv);
     > #        ^      ~~~~~~~~~~~~
     > #  469|           syslog(LOG_INFO, "Version mismatch, restarting");
     > #  470|           sleep(1);
     > #  471|->         execvp(orig_argv[0], orig_argv);
     > #  472|       }
     > #  473|
    
    Signed-off-by: default avatarVictor Toso <victortoso@redhat.com>
    Acked-by: default avatarUri Lublin <uril@redhat.com>
    cedab5fe