Merge pull request #454 from nfi/contrib/uiplib-unspec-addr

uiplib: ensure output string is null-terminated when printing the unspecified address
This commit is contained in:
George Oikonomou 2018-04-25 22:57:24 +01:00 committed by GitHub
commit 4151461289
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -250,9 +250,11 @@ uiplib_ipaddr_snprint(char *buf, size_t size, const uip_ipaddr_t *addr)
} }
} }
if(n >= size - 1) { /*
buf[size - 1] = '\0'; * Make sure the output string is always null-terminated.
} */
buf[MIN(n, size - 1)] = '\0';
return n; return n;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/