diff options
author | sam <sam@FreeBSD.org> | 2005-02-23 22:44:38 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2005-02-23 22:44:38 +0000 |
commit | 9f549c4137bc9f34e2013af710160f0d90a8af4a (patch) | |
tree | dcc31d32b9118884661c95876679fa376fa0ae00 /sys/netncp | |
parent | e9418b71b6bf695d7c977c26a29113cb19f3d70c (diff) | |
download | FreeBSD-src-9f549c4137bc9f34e2013af710160f0d90a8af4a.zip FreeBSD-src-9f549c4137bc9f34e2013af710160f0d90a8af4a.tar.gz |
avoid potential null ptr derefs
Noticed by: Coverity Prevent analysis tool
Diffstat (limited to 'sys/netncp')
-rw-r--r-- | sys/netncp/ncp_nls.c | 13 |
1 files changed, 11 insertions, 2 deletions
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 <sys/param.h> #include <sys/errno.h> +#include <sys/systm.h> #include <netncp/ncp.h> #include <netncp/ncp_nls.h> @@ -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; |