From 69d93c899a581d9f7bd6be332088c4514d15adcc Mon Sep 17 00:00:00 2001 From: Sam Leffler Date: Wed, 23 Feb 2005 22:44:38 +0000 Subject: [PATCH] avoid potential null ptr derefs Noticed by: Coverity Prevent analysis tool --- sys/netncp/ncp_nls.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sys/netncp/ncp_nls.c b/sys/netncp/ncp_nls.c index 6a8b57304e7f..bb746fc1474f 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;