diff --git a/include/lldp.h b/include/lldp.h index 03f5c7e..8e36141 100644 --- a/include/lldp.h +++ b/include/lldp.h @@ -58,8 +58,10 @@ typedef __u64 u64; #else #define STRNCPY_TERMINATED(DEST, SRC, N) \ do { \ - strncpy (DEST, SRC, N - 1); \ - DEST[N - 1] = '\0'; \ + if((N) > 0) { \ + strncpy (DEST, SRC, (N) - 1); \ + DEST[(N) - 1] = '\0'; \ + } \ } while (false) #endif