From 9f549c4137bc9f34e2013af710160f0d90a8af4a Mon Sep 17 00:00:00 2001 From: sam Date: Wed, 23 Feb 2005 22:44:38 +0000 Subject: avoid potential null ptr derefs Noticed by: Coverity Prevent analysis tool --- sys/netncp/ncp_nls.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'sys/netncp') diff --git a/sys/netncp/ncp_nls.c b/sys/netncp/ncp_nls.c index 6a8b573..bb746fc 100644 --- a/sys/netncp/ncp_nls.c +++ b/sys/netncp/ncp_nls.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -245,7 +246,11 @@ ncp_pathcopy(const char *src, char *dst, int len, struct ncp_nlstables *nt) u_char c; /* char *d = dst, *s = src;*/ - donls = (nt && (nt->opt & NWHP_NLS)); + if (nt == NULL) { + ovbcopy(src, dst, len); + return; + } + donls = (nt->opt & NWHP_NLS); if ((nt->opt & (NWHP_UPPER | NWHP_LOWER)) == 0) { while (len--) { *dst = donls ? nt->u2n[(u_char)*src] : *src; @@ -280,7 +285,11 @@ ncp_path2unix(char *src, char *dst, int len, struct ncp_nlstables *nt) { /* char *d = dst, *s = src;*/ /* printf("toux(%02x): %s:",nt->opt, s);*/ - donls = (nt && (nt->opt & NWHP_NLS)); + if (nt == NULL) { + ovbcopy(src, dst, len); + return; + } + donls = (nt->opt & NWHP_NLS); if ((nt->opt & (NWHP_UPPER | NWHP_LOWER)) == 0) { while (len--) { c = *src; -- cgit v1.1