]> The Tcpdump Group git mirrors - libpcap/blobdiff - pcap-int.h
strncpy_s() can act like strlcpy() all by itself.
[libpcap] / pcap-int.h
index 007e470a7057b7beda86c2911d86602a14d9411c..288e6ae39cabd8fa4ae333df029df53874943e40 100644 (file)
@@ -365,18 +365,25 @@ struct oneshot_userdata {
 int    pcap_offline_read(pcap_t *, int, pcap_handler, u_char *);
 
 #ifndef HAVE_STRLCPY
- #if !defined(_WIN32)
+ /*
+  * Macro that does the same thing as strlcpy().
+  */
+ #ifdef _WIN32
+  /*
+   * strncpy_s() is supported at least back to Visual
+   * Studio 2005.
+   */
   #define strlcpy(x, y, z) \
-       (strncpy((x), (y), (z)), \
-        ((z) <= 0 ? 0 : ((x)[(z) - 1] = '\0')), \
-        (void) strlen((y)))
+       strncpy_s((x), (z), (y), _TRUNCATE)
+
  #else
   #define strlcpy(x, y, z) \
-       (strncpy_s((x), PCAP_ERRBUF_SIZE, (y), (z)), \
+       (strncpy((x), (y), (z)), \
         ((z) <= 0 ? 0 : ((x)[(z) - 1] = '\0')), \
         (void) strlen((y)))
  #endif
 #endif
+
 #include <stdarg.h>
 
 /*