Quit function if no connection instead of assigning variable that
authorwwp <wwp@free.fr>
Wed, 11 Jan 2017 15:09:08 +0000 (16:09 +0100)
committerwwp <wwp@free.fr>
Wed, 11 Jan 2017 15:09:08 +0000 (16:09 +0100)
will be overwriten right after.
Fixes Coverity CID #1372370.

src/plugins/clamd/libclamd/clamd-plugin.c

index a45860a9b611a83524c802d942c5593b526a164f..8152d1dfd75b7b8758d6cb61760c1bc566d8bedb 100644 (file)
@@ -513,7 +513,7 @@ Clamd_Stat clamd_verify_email(const gchar* path, response* result) {
        }
        sock = create_socket();
        if (sock < 0) {
        }
        sock = create_socket();
        if (sock < 0) {
-               debug_print("no connection\n");
+               debug_print("no connection (socket create)\n");
                return NO_CONNECTION;
        }
        memset(buf, '\0', sizeof(buf));
                return NO_CONNECTION;
        }
        memset(buf, '\0', sizeof(buf));
@@ -535,8 +535,8 @@ Clamd_Stat clamd_verify_email(const gchar* path, response* result) {
                command = g_strconcat(scan, " ", path, "\n", NULL);
                debug_print("command: %s\n", command);
                if (write(sock, command, strlen(command)) == -1) {
                command = g_strconcat(scan, " ", path, "\n", NULL);
                debug_print("command: %s\n", command);
                if (write(sock, command, strlen(command)) == -1) {
-                       debug_print("no connection\n");
-                       stat = NO_CONNECTION;
+                       debug_print("no connection (socket write)\n");
+                       return NO_CONNECTION;
                }
                g_free(command);
                memset(buf, '\0', sizeof(buf));
                }
                g_free(command);
                memset(buf, '\0', sizeof(buf));