Fixed invalid read issue when printing txt_record 56/187156/1 accepted/tizen/unified/20180822.093801 submit/tizen/20180821.002826
authorSaurav Babu <saurav.babu@samsung.com>
Mon, 20 Aug 2018 09:23:27 +0000 (14:53 +0530)
committerSaurav Babu <saurav.babu@samsung.com>
Mon, 20 Aug 2018 09:23:27 +0000 (14:53 +0530)
g_strdup only duplicates the string where as here it was required to
copy txt_len bytes. When txt_len is greater than length of txt_record
then invalid read issue occured as only length of txt_record was copied

Change-Id: Ifda849d7b24a030a38bc5bfcff870ac66b044588
Signed-off-by: Saurav Babu <saurav.babu@samsung.com>
src/dns-sd/dns-sd.c

index bd744e2c0a2cfbcd45efa095564909be2db499f1..70dbb09c9e53e443614b06b0702aef24b80150a9 100644 (file)
@@ -1824,7 +1824,7 @@ int dnssd_service_get_all_txt_record(dnssd_service_h dnssd_service,
                dnssd_found_data_s *found = NULL;       //LCOV_EXCL_LINE
                found = GET_FOUND_DATA_P(local_handle); //LCOV_EXCL_LINE
 
-               *value = g_strdup(found->txt_record);   //LCOV_EXCL_LINE
+               *value = g_strndup(found->txt_record, found->txt_len);  //LCOV_EXCL_LINE
                *length = found->txt_len;       //LCOV_EXCL_LINE
        } else {