ipaccess-config: properly create swload

Instead of 20, use the actual buffer sizes of struct sw_load, which are 255.
Previous code would truncate a longer string at 20 without(!) NUL termination.

In the _len members, store the actual length copied. In previous code, if the
source string were longer than 20, we would store only 20 (without NUL term)
but still reflect the longer length of the source string.

Fix both of these issues for sw_load.file_id / file_id_len and
sw_load.file_version / file_version_len.

Change-Id: I2e34a1348a290d3f58dd830d08da65b94b3270db
This commit is contained in:
Neels Hofmeyr 2017-03-08 18:30:45 +01:00 committed by Harald Welte
parent 5265bea76c
commit 1fe2647c5d
1 changed files with 6 additions and 4 deletions

View File

@ -609,11 +609,13 @@ static struct abis_nm_sw_desc *create_swload(struct sdp_header *header)
load = talloc_zero(tall_ctx_config, struct abis_nm_sw_desc);
strncpy((char *)load->file_id, header->firmware_info.sw_part, 20);
load->file_id_len = strlen(header->firmware_info.sw_part) + 1;
osmo_strlcpy((char *)load->file_id, header->firmware_info.sw_part,
sizeof(load->file_id));
load->file_id_len = strlen((char*)load->file_id) + 1;
strncpy((char *)load->file_version, header->firmware_info.version, 20);
load->file_version_len = strlen(header->firmware_info.version) + 1;
osmo_strlcpy((char *)load->file_version, header->firmware_info.version,
sizeof(load->file_version));
load->file_version_len = strlen((char*)load->file_version) + 1;
return load;
}