From: Christian Göttsche <cgzones@xxxxxxxxxxxxxx> Signed-off-by: Christian Göttsche <cgzones@xxxxxxxxxxxxxx> --- libsemanage/src/parse_utils.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libsemanage/src/parse_utils.c b/libsemanage/src/parse_utils.c index d9b12763..d3bc148b 100644 --- a/libsemanage/src/parse_utils.c +++ b/libsemanage/src/parse_utils.c @@ -290,14 +290,12 @@ int parse_fetch_string(semanage_handle_t * handle, goto err; } - tmp_str = (char *)malloc(len + 1); + tmp_str = strndup(start, len); if (!tmp_str) { ERR(handle, "out of memory"); goto err; } - strncpy(tmp_str, start, len); - *(tmp_str + len) = '\0'; *str = tmp_str; return STATUS_SUCCESS; -- 2.45.2