Reserve last char in array for '\0' to ensure termination
of the string.
Fix for:
CID
1128383 (#1 of 1): Buffer not null terminated (BUFFER_SIZE_WARNING)
buffer_size_warning: Calling strncpy with a maximum size argument
of 1000 bytes on destination array secret of size 1000 bytes might
leave the destination string unterminated.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
}
/* secret is only added to kernel options as
- backwards compatilbity, if add_key doesn't
+ backwards compatibility, if add_key doesn't
recognize our keytype; hence, it is skipped
here and appended to options on add_key
failure */
- strncpy(secret, value, sizeof(secret));
+ size_t len = sizeof(secret);
+ strncpy(secret, value, len-1);
+ secret[len-1] = '\0';
saw_secret = secret;
skip = 1;
} else if (strncmp(data, "name", 4) == 0) {