Re: [systemd-devel] [PATCH 1/2] libsystemd-network: Avoid potential NULL dereference in test-lldp

2015-02-10 Thread Lennart Poettering
On Sun, 08.02.15 22:21, Philippe De Swert (philippedesw...@gmail.com) wrote:

 As a malloc0 could fail, doing a strncpy without checking could
 cause issues. Adding an assert should be good enough and in line
 with other similar routines in the code.

Thanks, applied.

 
 Found with Coverity Fixes: CID#1261402
 ---
  src/libsystemd-network/test-lldp.c | 1 +
  1 file changed, 1 insertion(+)
 
 diff --git a/src/libsystemd-network/test-lldp.c 
 b/src/libsystemd-network/test-lldp.c
 index 288aac5..2e6bf14 100644
 --- a/src/libsystemd-network/test-lldp.c
 +++ b/src/libsystemd-network/test-lldp.c
 @@ -166,6 +166,7 @@ static int lldp_parse_system_name_tlv(tlv_packet *m) {
  assert_se(tlv_packet_read_string(m, str, length) = 0);
  
  p = malloc0(length + 1);
 +assert_se(p);
  strncpy(p, str, length);
  
  assert_se(streq(p, TEST_LLDP_TYPE_SYSTEM_NAME) == 1);
 -- 
 2.1.4
 
 ___
 systemd-devel mailing list
 systemd-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 1/2] libsystemd-network: Avoid potential NULL dereference in test-lldp

2015-02-08 Thread Philippe De Swert
As a malloc0 could fail, doing a strncpy without checking could
cause issues. Adding an assert should be good enough and in line
with other similar routines in the code.

Found with Coverity Fixes: CID#1261402
---
 src/libsystemd-network/test-lldp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/libsystemd-network/test-lldp.c 
b/src/libsystemd-network/test-lldp.c
index 288aac5..2e6bf14 100644
--- a/src/libsystemd-network/test-lldp.c
+++ b/src/libsystemd-network/test-lldp.c
@@ -166,6 +166,7 @@ static int lldp_parse_system_name_tlv(tlv_packet *m) {
 assert_se(tlv_packet_read_string(m, str, length) = 0);
 
 p = malloc0(length + 1);
+assert_se(p);
 strncpy(p, str, length);
 
 assert_se(streq(p, TEST_LLDP_TYPE_SYSTEM_NAME) == 1);
-- 
2.1.4

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel