jwbensley / Etherate

Linux CLI Ethernet and MPLS Testing Tool
MIT License
176 stars 19 forks source link

Make strncpy() zero value safe #14

Closed jwbensley closed 7 years ago

jwbensley commented 7 years ago

Email from Bruno:

In the file functions.cpp, function get_interface_mtu_by_name(), the lines :

    const uint8_t *pIF_NAME = TEST_INTERFACE->IF_NAME;
    strcpy(ifr.ifr_name,(char*) pIF_NAME);

should be replaced by

strncpy(ifr.ifr_name, (char *) TEST_INTERFACE->IF_NAME, sizeof(ifr.ifr_name));

as TEST_INTERFACE->IF_NAME is not guaranteed to be zero-terminated.

This is in relation to https://github.com/jwbensley/Etherate/blob/master/functions.cpp#L924

jwbensley commented 7 years ago

Fixed in beta 0.12.