Fix not null terminated string 11/172211/4
authorJiung <jiung.yu@samsung.com>
Mon, 12 Mar 2018 23:50:16 +0000 (08:50 +0900)
committerJiung <jiung.yu@samsung.com>
Wed, 14 Mar 2018 00:55:35 +0000 (09:55 +0900)
Change-Id: Ie3ac0e977876dd2f59ca3fcdc5be44f67240bd69
Signed-off-by: Yu jiung <jiung.yu@samsung.com>
packaging/capi-network-nsd.spec
src/dns-sd/dns-sd.c
src/ssdp/ssdp.c

index 6f1700956b8a914cfd26c3b21d32fbb1b4d6003f..1fd0ba7b39e2bfcbc303d03eb31147352d883dbc 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-network-nsd
 Summary:    A Network Service Discovery libraries in Native API
-Version:    0.0.20
+Version:    0.0.21
 Release:    1
 Group:      System/Network
 License:    Apache-2.0
index d63d1e4b6be0a5e665c8486ae1685b694c292433..53d615a0e413dffe9246d74c4435152072b3a746 100644 (file)
@@ -87,19 +87,20 @@ static bool __dnssd_check_permission()
                return false;
        }
 
-       bzero(smack_label, SMACK_LABEL_LEN + 1);
+       memset(smack_label, 0x00, SMACK_LABEL_LEN + 1);
 
        fd = fopen("/proc/self/attr/current", "r");
        if (fd == NULL) {
                DNSSD_LOGE("Failed to open /proc/self/attr/current");
                return false;
        }
-       ret = fread(smack_label, sizeof(smack_label), 1, fd);
-       fclose(fd);
-       if (ret < 0) {
+       ret = fread(smack_label, SMACK_LABEL_LEN, 1, fd);
+       if (ret == 0 && ferror(fd)) {
                DNSSD_LOGE("Failed to read /proc/self/attr/current");
+               fclose(fd);
                return false;
        }
+       fclose(fd);
 
        snprintf(uid, sizeof(uid), "%d", getuid());
 
index 4da1f56d853020a6ae099f41ee2f446ec9c109f4..3617c44be58aab992cc7e28ca4ece027e300a916 100644 (file)
@@ -163,19 +163,20 @@ static bool __ssdp_check_permission()
                return false;
        }
 
-       bzero(smack_label, SMACK_LABEL_LEN + 1);
+       memset(smack_label, 0x00, SMACK_LABEL_LEN + 1);
 
        fd = fopen("/proc/self/attr/current", "r");
        if (fd == NULL) {
                SSDP_LOGE("Failed to open /proc/self/attr/current");
                return false;
        }
-       ret = fread(smack_label, sizeof(smack_label), 1, fd);
-       fclose(fd);
-       if (ret < 0) {
+       ret = fread(smack_label, SMACK_LABEL_LEN, 1, fd);
+       if (ret == 0 && ferror(fd)) {
                SSDP_LOGE("Failed to read /proc/self/attr/current");
+               fclose(fd);
                return false;
        }
+       fclose(fd);
 
        snprintf(uid, sizeof(uid), "%d", getuid());