[FIX] MSG_BINARY_INFO daemon crash if file type is not ELF 47/32047/3
authorVitaliy Cherepanov <v.cherepanov@samsung.com>
Mon, 15 Dec 2014 09:03:20 +0000 (12:03 +0300)
committerVitaliy Cherepanov <v.cherepanov@samsung.com>
Mon, 15 Dec 2014 09:57:29 +0000 (12:57 +0300)
Change-Id: I5f967f6fe95a541868e360e1dd4b520fbf7d1074
Signed-off-by: Vitaliy Cherepanov <v.cherepanov@samsung.com>
daemon/da_protocol.c
daemon/elf.h

index 8bdc540..8ec2583 100644 (file)
@@ -838,7 +838,8 @@ static struct binary_ack* binary_ack_alloc(const char *filename)
        if (stat(filename, &decoy) == 0) {
                ba->type = get_binary_type(filename);
 
-               get_build_dir(builddir, filename);
+               if (ba->type != BINARY_TYPE_UNKNOWN)
+                       get_build_dir(builddir, filename);
 
                if (builddir[0] != '\0')
                        snprintf(binpath, sizeof(binpath), check_windows_path(builddir) ?
@@ -883,7 +884,11 @@ static int process_msg_binary_info(struct msg_buf_t *msg)
                if (new->type == BINARY_TYPE_FILE_NOT_EXIST) {
                        error_code = ERR_WRONG_MESSAGE_DATA;
                        LOGW("binary file not exists <%s>\n", str);
+               } else if (new->type == BINARY_TYPE_UNKNOWN) {
+                       error_code = ERR_WRONG_MESSAGE_DATA;
+                       LOGW("binary is not ELF binary <%s>\n", str);
                }
+
                if (new->binpath[0] == '\0')
                        LOGW("section '.debug_str' not found in <%s>\n", str);
                acks[i] = new;
index c66ae57..5f849b5 100644 (file)
@@ -33,8 +33,8 @@
 enum binary_type_t {
        BINARY_TYPE_NO_PIE = 0,
        BINARY_TYPE_PIE = 1,
-       BINARY_TYPE_UNKNOWN,
-       BINARY_TYPE_FILE_NOT_EXIST = 0xFFFFFFFF
+       BINARY_TYPE_UNKNOWN = -2,
+       BINARY_TYPE_FILE_NOT_EXIST = -1
 };
 
 uint32_t get_binary_type(const char *path);