mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-19 14:09:05 +03:00
client.c: fix -Wstringop-overflow warning in cmdline_token()
Calling strncpy() on the variable (and erroneous) calculated token length in cmdline_token() has caused stringop-overflow warning by GCC 8. This change fixes the error and replaces strncpy() by memcpy() to quieten the compiler.
This commit is contained in:
1 parent
a5f98ef639
commit
171f25e123
1 file changed
+4
-2
+4
-2
@@ -802,8 +802,10 @@ cmdline_proxy(char *arg) {
|
||||
|
||||
static inline void
|
||||
cmdline_token(char *arg) {
|
||||
strncpy((char *)the_token.s, arg, min(sizeof(_token_data), strlen(arg)));
|
||||
the_token.length = strlen(arg);
|
||||
the_token.length = min(sizeof(_token_data), strlen(arg));
|
||||
if (the_token.length > 0) {
|
||||
memcpy((char *)the_token.s, arg, the_token.length);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in new issue
Block a user