Fix svace issues 09/256609/2
authorSeonah Moon <seonah1.moon@samsung.com>
Thu, 8 Apr 2021 05:23:57 +0000 (14:23 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Thu, 8 Apr 2021 05:25:10 +0000 (14:25 +0900)
Change-Id: Id3be83c815b0a3af4046cf0b9ba89237c3be953f

src/vine-dp.cpp
tool/tool_run.cpp

index dfdde5e..b705f2b 100644 (file)
@@ -637,6 +637,7 @@ DPPubSub::DPPubSub(void *event_fd)
        mServiceName = "";
        mInitDiscNum = 1;
        mOpenState = VINE_DP_PUBSUB_OPEN_STATE_NONE;
+       mSdPubSubState = VINE_DP_PUBSUB_SD_STATE_NONE;
 
        // Network Info
        mAddrFamily = VINE_ADDRESS_FAMILY_DEFAULT;
index 836ce29..adcc484 100644 (file)
@@ -8,6 +8,7 @@
 #include <sys/syscall.h>
 #include <sys/timerfd.h>
 #include <stdio.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <unistd.h>
 
@@ -239,7 +240,8 @@ static void _message_timer_handler(void *user_data)
 static int _send_message_from_file(vine_dp_h dp)
 {
        unsigned char *buf;
-       size_t size, count = 0;
+       long size;
+       size_t count;
        int ret;
        FILE *file = fopen(vine_configs.file, "r");
 
@@ -249,6 +251,9 @@ static int _send_message_from_file(vine_dp_h dp)
        fseek(file, 0, SEEK_END);
 
        size = ftell(file);
+       if (size < 0 || size >= SIZE_MAX - 1) {
+               return -1;
+       }
        buf = (unsigned char *)calloc(sizeof(unsigned char), size + 1);
 
        fseek(file, 0, SEEK_SET);