[FIX] Svace issues 63/70963/1 accepted/tizen/common/20160525.155746 accepted/tizen/ivi/20160525.003333 accepted/tizen/mobile/20160525.003306 accepted/tizen/tv/20160525.003326 accepted/tizen/wearable/20160525.003318 submit/tizen/20160524.083432
authorAnatolii Nikulin <nikulin.a@samsung.com>
Mon, 23 May 2016 11:25:50 +0000 (14:25 +0300)
committerAnatolii Nikulin <nikulin.a@samsung.com>
Mon, 23 May 2016 11:30:03 +0000 (14:30 +0300)
-----------------------------------------------------
| WGID  | Type                      | File          |
|----------------------------------------------------
| 72423 | MEMORY_LEAK               | da_protocol.c |
| 78692 | PROC_USE.VULNERABLE       | utils.c       |
|---------------------------------------------------|

Change-Id: I4896f7aa780cf331d36f729ca1e9b4993c4c0ab4
Signed-off-by: Anatolii Nikulin <nikulin.a@samsung.com>
daemon/da_protocol.c
daemon/utils.c

index d7406bb..45d465b 100644 (file)
@@ -901,7 +901,7 @@ exit_fail:
 
 static int process_msg_binary_info(struct msg_buf_t *msg)
 {
-       int err;
+       int err = -1;
        uint32_t allocated_acks, i, bincount;
        enum ErrorCode error_code = ERR_NO;
 
@@ -966,23 +966,20 @@ static int process_msg_binary_info(struct msg_buf_t *msg)
        pack_int32(p, error_code);
        pack_int32(p, bincount);
 
-       for (i = 0; i != bincount; ++i) {
+       for (i = 0; i != bincount; ++i)
                p += binary_ack_pack(p, acks[i]);
-               binary_ack_free(acks[i]);
-       }
 
        printBuf((char *)msg_reply, msg_reply->len + sizeof(*msg_reply));
        err = send_reply(msg_reply);
        free(msg_reply);
 
-       return err;
-
 exit_fail_free_ack:
        for (i = 0; i < allocated_acks; i++)
                binary_ack_free(acks[i]);
        free(acks);
+
 exit_fail:
-       return -1;
+       return err;
 }
 
 static int process_msg_get_probe_map()
index bc02434..fca624d 100644 (file)
@@ -141,11 +141,12 @@ int remove_indir(const char *dirname)
 int change_user(const char *username)
 {
        struct passwd *pw;
-       int uid, gid;
+       struct passwd pw_entry;
+       char buf[1024];
+       int uid, gid, err;
 
-
-       pw = getpwnam(username);
-       if (!pw) {
+       err = getpwnam_r(username, &pw_entry, buf, sizeof(buf), &pw);
+       if (err || !pw) {
                LOGE("user %s is unknown\n", username);
                return -1;
        }