Add an assertion (n > 0) in strNcpy(), it may help to catch incorrect
authornbk <nbk>
Mon, 22 Aug 2005 16:52:52 +0000 (16:52 +0000)
committernbk <nbk>
Mon, 22 Aug 2005 16:52:52 +0000 (16:52 +0000)
use of the function.

src/lib/misc.c

index 93d83f0..50cb091 100644 (file)
@@ -41,6 +41,7 @@ static const char rcsid[] =
 
 #include       "missing.h"
 #include       "libradius.h"
+#include       "rad_assert.h"
 
 int            librad_dodns = 0;
 int            librad_debug = 0;
@@ -186,6 +187,8 @@ char *strNcpy(char *dest, const char *src, int n)
 {
        char *p = dest;
 
+       rad_assert(n > 0);
+
        while ((n > 1) && (*src)) {
                *(p++) = *(src++);