diff mbox

[2/2] validation: system: fix unterminated string

Message ID 1424104995-18327-2-git-send-email-mike.holmes@linaro.org
State Accepted
Commit 408ec8ab63aa99cbb9d711c45f2035f00aba7784
Headers show

Commit Message

Mike Holmes Feb. 16, 2015, 4:43 p.m. UTC
Calling strncpy with a maximum size argument of 128 bytes on destination
array "version_string" of size 128 bytes might leave the destination
string unterminated.

Fixes https://bugs.linaro.org/show_bug.cgi?id=1207

Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---
 test/validation/odp_system.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Maxim Uvarov Feb. 16, 2015, 5:03 p.m. UTC | #1
Reviewed-by: Maxim Uvarov <maxim.uvarov@linaro.org>

On 02/16/2015 07:43 PM, Mike Holmes wrote:
> Calling strncpy with a maximum size argument of 128 bytes on destination
> array "version_string" of size 128 bytes might leave the destination
> string unterminated.
>
> Fixes https://bugs.linaro.org/show_bug.cgi?id=1207
>
> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
> ---
>   test/validation/odp_system.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/test/validation/odp_system.c b/test/validation/odp_system.c
> index 65f857a..94ee712 100644
> --- a/test/validation/odp_system.c
> +++ b/test/validation/odp_system.c
> @@ -15,7 +15,8 @@ static void test_odp_version_numbers(void)
>   	char version_string[128];
>   	char *s = version_string;
>   
> -	strncpy(version_string, odp_version_api_str(), sizeof(version_string));
> +	strncpy(version_string, odp_version_api_str(),
> +		sizeof(version_string)-1);
>   
>   	while (*s) {
>   		if (isdigit(*s) || (strncmp(s, ".", 1) == 0)) {
diff mbox

Patch

diff --git a/test/validation/odp_system.c b/test/validation/odp_system.c
index 65f857a..94ee712 100644
--- a/test/validation/odp_system.c
+++ b/test/validation/odp_system.c
@@ -15,7 +15,8 @@  static void test_odp_version_numbers(void)
 	char version_string[128];
 	char *s = version_string;
 
-	strncpy(version_string, odp_version_api_str(), sizeof(version_string));
+	strncpy(version_string, odp_version_api_str(),
+		sizeof(version_string)-1);
 
 	while (*s) {
 		if (isdigit(*s) || (strncmp(s, ".", 1) == 0)) {