Browse Source

net: Make copy_filename() accept NULL src

Rather than crashing, check the src ptr and set dst to empty string.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Joe Hershberger 6 years ago
parent
commit
16cf145fd6
1 changed files with 2 additions and 2 deletions
  1. 2 2
      net/net.c

+ 2 - 2
net/net.c

@@ -1522,12 +1522,12 @@ void net_set_udp_header(uchar *pkt, struct in_addr dest, int dport, int sport,
 
 void copy_filename(char *dst, const char *src, int size)
 {
-	if (*src && (*src == '"')) {
+	if (src && *src && (*src == '"')) {
 		++src;
 		--size;
 	}
 
-	while ((--size > 0) && *src && (*src != '"'))
+	while ((--size > 0) && src && *src && (*src != '"'))
 		*dst++ = *src++;
 	*dst = '\0';
 }