Hey Waldek/Friends,

Uhm, I see, let me double check it
Because I just adapted the code and my c/c++ skills are limited
In any case, let's keep in touch


Kind regards,

Geraldo Netto
Sapere Aude => Non dvcor, dvco
http://exdev.sf.net/


On Fri, 2 Nov 2018 at 00:33, Waldek Kozaczuk <[email protected]> wrote:

> I think this patch fixes the warning but the underlying test has the bugs
> - should not we be using strlen() instead of sizeof() which simply returns
> 8 (size of the pointer) instead of intended length of the string. Do we
> actually need strncat - shouldn't strcat be enough? I guess you are also
> assuming that total length of first_block and second_block is not longer
> than 10?
>
> On Wednesday, October 31, 2018 at 11:21:42 PM UTC-4, Geraldo Netto wrote:
>>
>> this patch fix the following strncat() calls by passing proper sizeof():
>> /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]>
>> ---
>>  tests/tst-crypt.c | 5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/tests/tst-crypt.c b/tests/tst-crypt.c
>> index 7ccc8235..dc9a6341 100644
>> --- a/tests/tst-crypt.c
>> +++ b/tests/tst-crypt.c
>> @@ -8,11 +8,12 @@
>>  char* concat_str(char* first_block, char* second_block) {
>>          static char tmp[10];
>>          memset(tmp, 0, sizeof(tmp));
>> -        strncat(tmp, first_block, sizeof(first_block));
>> -        strncat(tmp, second_block, sizeof(second_block));
>> +        strncat(tmp, first_block, sizeof(char*));
>> +        strncat(tmp, second_block, sizeof(char*));
>>          return tmp;
>>  }
>>
>> +// to test as a standalone app: gcc tests/tst-crypt.c -lcrypt -o crypt
>>  int main(void) {
>>          // http://man7.org/linux/man-pages/man3/crypt.3.html
>>          char password[] = "Ab(d3";
>> --
>> 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.
>

-- 
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