[APR-6542]libstrongswan: fix prevent issue (CID: 330540)
authorSeungah Lim <sss.lim@samsung.com>
Thu, 17 Dec 2020 02:40:34 +0000 (11:40 +0900)
committerI am Robot <robot_ap@samsung.com>
Mon, 21 Dec 2020 16:26:59 +0000 (01:26 +0900)
[Issue] S5E9815-5808
[Problem] CID 330540 Buffer not null terminated.
[Cause] buffer size warning : Calling strncpy with a maximun size
    argument of 16 bytes on destination array this->if_name of size
    might leave the destination string unterminated.
[Solution] fix prevent issue by updating strncpy.

Change-Id: I0735a44c82672d4903dc833676cc4bc02bb3f91a
Signed-off-by: Seungah Lim <sss.lim@samsung.com>
src/libstrongswan/networking/tun_device.c

index 676d69a6bb5838496fbc3480432ddbda62478ed7..3162733bfcead7e7652c8ed46767d5444a72144d 100755 (executable)
@@ -653,7 +653,7 @@ tun_device_t *xfrm_device_create(const char *name)
                .tunfd = -1,
                .sock = -1,
        );
-       strncpy(this->if_name, name, IFNAMSIZ);
+       strncpy(this->if_name, name, IFNAMSIZ - 1);
        this->addresses = linked_list_create();
        this->is_xfrm_device = TRUE;