From 0a9a829a652a8ab97d66d28464811848a618df7f Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 15 Sep 2008 23:37:51 +0000 Subject: [PATCH] malloc(strlen(X) + 1) followed by strcpy(result-of-malloc, str) is equivalent to strdup(str); use that, so people don't freak out upon seeing a strcpy() call that, out of context, looks as if it's not buffer-overflow-safe. --- Win32/Src/getaddrinfo.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Win32/Src/getaddrinfo.c b/Win32/Src/getaddrinfo.c index 813313f..0cd816c 100644 --- a/Win32/Src/getaddrinfo.c +++ b/Win32/Src/getaddrinfo.c @@ -51,7 +51,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/Win32/Src/getaddrinfo.c,v 1.2 2003-11-15 23:24:06 guy Exp $"; + "@(#) $Header: /tcpdump/master/libpcap/Win32/Src/getaddrinfo.c,v 1.3 2008-09-15 23:37:51 guy Exp $"; #endif #include @@ -981,10 +981,9 @@ get_canonname(pai, ai, str) const char *str; { if ((pai->ai_flags & AI_CANONNAME) != 0) { - ai->ai_canonname = (char *)malloc(strlen(str) + 1); + ai->ai_canonname = strdup(str); if (ai->ai_canonname == NULL) return EAI_MEMORY; - strcpy(ai->ai_canonname, str); } return 0; }