Hi,

This is almost correct except tmp of size 8 is not enough - I think you 
need 3 + 5 + 1(null terminator) at least. I would simply keep original 10 
length of tmp,

On Sunday, November 4, 2018 at 11:29:49 AM UTC-5, Geraldo Netto wrote:
>
> this patch fixes the following warnings: 
> /home/netto/Desktop/osv/osv-tomcat9/tests/tst-crypt.c: In function 
> ‘concat_str’: 
> /home/netto/Desktop/osv/osv-tomcat9/tests/tst-crypt.c:9:34: warning: 
> argument to ‘sizeof’ in ‘strncat’ call is the same expression as the 
> source; did you mean to provide an explicit length? 
> [-Wsizeof-pointer-memaccess] 
>   strncat(tmp, first_block, sizeof(first_block)); 
>                                   ^ 
> /home/netto/Desktop/osv/osv-tomcat9/tests/tst-crypt.c:10:35: warning: 
> argument to ‘sizeof’ in ‘strncat’ call is the same expression as the 
> source; did you mean to provide an explicit length? 
> [-Wsizeof-pointer-memaccess] 
>   strncat(tmp, second_block, sizeof(second_block)); 
>                                    ^ 
>
> Signed-off-by: geraldo netto <[email protected] <javascript:>> 
> --- 
>  tests/tst-crypt.c | 6 +++--- 
>  1 file changed, 3 insertions(+), 3 deletions(-) 
>
> diff --git a/tests/tst-crypt.c b/tests/tst-crypt.c 
> index 7ccc8235..abcec95f 100644 
> --- a/tests/tst-crypt.c 
> +++ b/tests/tst-crypt.c 
> @@ -6,10 +6,10 @@ 
>  #include <crypt.h> 
>   
>  char* concat_str(char* first_block, char* second_block) { 
> -        static char tmp[10]; 
> +        static char tmp[8]; 
>          memset(tmp, 0, sizeof(tmp)); 
> -        strncat(tmp, first_block, sizeof(first_block)); 
> -        strncat(tmp, second_block, sizeof(second_block)); 
> +        strcat(tmp, first_block); 
> +        strcat(tmp, second_block); 
>          return tmp; 
>  } 
>   
> -- 
> 2.17.1 
>
>

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to