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>
This commit is contained in:
Joe Hershberger 2018-07-03 19:36:41 -05:00
parent 3855cad623
commit 16cf145fd6

View file

@ -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';
}