summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2019-01-20 09:23:49 +0200
committerToomas Soome <tsoome@me.com>2019-04-24 09:46:32 +0300
commite9f74ea56f674c729c7fa4812e7fc668a9c24070 (patch)
tree94937994213b35a675f50114a98d594771acea9d
parent0f677ac901babf1fada10fcc386de1c3d4d4ecad (diff)
downloadillumos-joyent-e9f74ea56f674c729c7fa4812e7fc668a9c24070.tar.gz
10738 sockfs: NULL pointer errors
Reviewed by: Robert Mustacchi <rm@joyent.com> Reviewed by: Andy Fiddaman <andy@omniosce.org> Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r--usr/src/uts/common/fs/sockfs/nl7c.c51
-rwxr-xr-xusr/src/uts/common/fs/sockfs/nl7ctokgen5
-rw-r--r--usr/src/uts/common/fs/sockfs/nl7curi.c17
-rw-r--r--usr/src/uts/common/fs/sockfs/socktpi.c28
4 files changed, 40 insertions, 61 deletions
diff --git a/usr/src/uts/common/fs/sockfs/nl7c.c b/usr/src/uts/common/fs/sockfs/nl7c.c
index 88584eda68..c76dada8d7 100644
--- a/usr/src/uts/common/fs/sockfs/nl7c.c
+++ b/usr/src/uts/common/fs/sockfs/nl7c.c
@@ -51,6 +51,8 @@
#include <sys/systm.h>
#include <sys/strsun.h>
#include <sys/strsubr.h>
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
#include <inet/common.h>
#include <inet/ip.h>
#include <inet/led.h>
@@ -267,26 +269,6 @@ nl7c_mi_report_addr(mblk_t *mp)
}
/*
- * ASCII to unsigned.
- *
- * Note, it's assumed that *p is a valid zero byte terminated string.
- */
-
-static unsigned
-atou(const char *p)
-{
- int c;
- int v = 0;
-
- /* Shift and add digit by digit */
- while ((c = *p++) != NULL && isdigit(c)) {
- v *= 10;
- v += c - '0';
- }
- return (v);
-}
-
-/*
* Inet ASCII to binary.
*
* Note, it's assumed that *s is a valid zero byte terminated string, and
@@ -417,7 +399,7 @@ ncaportconf_read(void)
parse = EOL;
}
} else if (c == '=') {
- if (*tok != NULL) {
+ if (*tok != '\0') {
/* Only know one token, skip */
parse = EOL;
break;
@@ -435,7 +417,7 @@ ncaportconf_read(void)
case ADDR:
if (c == '/') {
/* addr/port separator, end of addr */
- *stringp = NULL;
+ *stringp = 0;
if (inet_atob(string, addrp)) {
/* Bad addr, skip */
parse = EOL;
@@ -469,9 +451,16 @@ ncaportconf_read(void)
}
break;
} else if (c == '#' || isspace(c)) {
+ unsigned long result = 0;
+
/* End of port number, convert */
- *stringp = NULL;
- addrp->port = ntohs(atou(string));
+ *stringp = '\0';
+ if (ddi_strtoul(string, NULL, 10, &result)
+ != 0) {
+ parse = EOL;
+ break;
+ }
+ addrp->port = ntohs(result);
/* End of parse, add entry */
nl7c_addr_add(addrp);
@@ -582,7 +571,7 @@ ncakmodconf_read(void)
* Found EOL, if tok found done,
* else start on next-line.
*/
- if (*tok == NULL) {
+ if (*tok == '\0') {
nl7c_enabled = B_TRUE;
goto done;
}
@@ -721,11 +710,11 @@ ncalogdconf_read(void)
* Found tok separator, if tok found get
* tok text, else skip rest of line.
*/
- if (tokstatusp != NULL && *tokstatusp == NULL)
+ if (tokstatusp != NULL && *tokstatusp == '\0')
tok = tokstatus;
- else if (toksizep != NULL && *toksizep == NULL)
+ else if (toksizep != NULL && *toksizep == '\0')
tok = toksize;
- else if (tokfilep != NULL && *tokfilep == NULL)
+ else if (tokfilep != NULL && *tokfilep == '\0')
tok = tokfile;
if (tok != NULL)
parse = TEXT;
@@ -746,7 +735,7 @@ ncalogdconf_read(void)
* (if any) and start on next line.
*/
if (tok == tokstatus) {
- if (*++tokstatusp == NULL)
+ if (*++tokstatusp == '\0')
nl7c_logd_enabled = B_TRUE;
} else if (tok == toksize) {
file_size = sz;
@@ -761,7 +750,7 @@ ncalogdconf_read(void)
}
parse = START;
} else if (tok == tokstatus) {
- if (! isalpha(c) || *++tokstatusp == NULL ||
+ if (! isalpha(c) || *++tokstatusp == '\0' ||
c != *tokstatusp) {
/* Not enabled, skip line */
parse = EOL;
@@ -921,7 +910,7 @@ nl7c_process(struct sonode *so, boolean_t nonblocking)
clock_t timout;
rval_t rval;
uchar_t pri;
- int pflag;
+ int pflag;
int error;
boolean_t more;
boolean_t ret = B_FALSE;
diff --git a/usr/src/uts/common/fs/sockfs/nl7ctokgen b/usr/src/uts/common/fs/sockfs/nl7ctokgen
index d3dfe2ed20..1cdf1d2d1f 100755
--- a/usr/src/uts/common/fs/sockfs/nl7ctokgen
+++ b/usr/src/uts/common/fs/sockfs/nl7ctokgen
@@ -20,9 +20,6 @@
#
# CDDL HEADER END
#
-#
-#ident "%Z%%M% %I% %E% SMI"
-#
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
@@ -60,7 +57,7 @@ NAME=${NAME%.txt}
TOKEN="$TOKEN
token_t $NAME[] = {
$ELE
- {NULL}
+ {0}
};
#define ${NAME}_cnt (sizeof ($NAME) / sizeof (*$NAME))
diff --git a/usr/src/uts/common/fs/sockfs/nl7curi.c b/usr/src/uts/common/fs/sockfs/nl7curi.c
index c6818babe7..a8d46d0fe0 100644
--- a/usr/src/uts/common/fs/sockfs/nl7curi.c
+++ b/usr/src/uts/common/fs/sockfs/nl7curi.c
@@ -926,7 +926,7 @@ add:
ruri->hit = 0;
ruri->expire = -1;
ruri->response.sz = 0;
- ruri->proc = (struct sonode *)~NULL;
+ ruri->proc = (struct sonode *)~0;
cv_init(&ruri->waiting, NULL, CV_DEFAULT, NULL);
mutex_init(&ruri->proclock, NULL, MUTEX_DEFAULT, NULL);
uri_add(ruri, RW_READER, nonblocking);
@@ -1276,7 +1276,7 @@ nl7c_readfile(file_t *fp, u_offset_t *off, int *len, int max, int *ret)
int
nl7c_sendfilev(struct sonode *so, u_offset_t *fileoff, sendfilevec_t *sfvp,
- int sfvc, ssize_t *xfer)
+ int sfvc, ssize_t *xfer)
{
sotpi_info_t *sti = SOTOTPI(so);
uri_desc_t *uri = (uri_desc_t *)sti->sti_nl7c_uri;
@@ -1480,7 +1480,7 @@ void
nl7c_close(struct sonode *so)
{
sotpi_info_t *sti = SOTOTPI(so);
- uri_desc_t *uri = (uri_desc_t *)sti->sti_nl7c_uri;
+ uri_desc_t *uri = (uri_desc_t *)sti->sti_nl7c_uri;
if (uri == NULL) {
/*
@@ -1585,15 +1585,8 @@ uri_segmap_map(uri_rd_t *rdp, int bytes)
*/
static mblk_t *
-uri_desb_chop(
- char **data,
- size_t *sz,
- int *bytes,
- uri_desb_t *temp,
- int max_mblk,
- char *eoh,
- mblk_t *persist
-)
+uri_desb_chop(char **data, size_t *sz, int *bytes, uri_desb_t *temp,
+ int max_mblk, char *eoh, mblk_t *persist)
{
char *ldata = *data;
size_t lsz = *sz;
diff --git a/usr/src/uts/common/fs/sockfs/socktpi.c b/usr/src/uts/common/fs/sockfs/socktpi.c
index bbeee8ce4b..cbb8eccd23 100644
--- a/usr/src/uts/common/fs/sockfs/socktpi.c
+++ b/usr/src/uts/common/fs/sockfs/socktpi.c
@@ -88,12 +88,12 @@
/*
* Possible failures when memory can't be allocated. The documented behavior:
*
- * 5.5: 4.X: XNET:
+ * 5.5: 4.X: XNET:
* accept: ENOMEM/ENOSR/EINTR - (EINTR) ENOMEM/ENOBUFS/ENOSR/
* EINTR
* (4.X does not document EINTR but returns it)
* bind: ENOSR - ENOBUFS/ENOSR
- * connect: EINTR EINTR ENOBUFS/ENOSR/EINTR
+ * connect: EINTR EINTR ENOBUFS/ENOSR/EINTR
* getpeername: ENOMEM/ENOSR ENOBUFS (-) ENOBUFS/ENOSR
* getsockname: ENOMEM/ENOSR ENOBUFS (-) ENOBUFS/ENOSR
* (4.X getpeername and getsockname do not fail in practice)
@@ -182,8 +182,8 @@ static struct sonode *sotpi_create(struct sockparams *, int, int, int, int,
static boolean_t sotpi_info_create(struct sonode *, int);
static void sotpi_info_init(struct sonode *);
-static void sotpi_info_fini(struct sonode *);
-static void sotpi_info_destroy(struct sonode *);
+static void sotpi_info_fini(struct sonode *);
+static void sotpi_info_destroy(struct sonode *);
/*
* Do direct function call to the transport layer below; this would
@@ -202,7 +202,7 @@ extern void sigunintr(k_sigset_t *);
static int sotpi_unbind(struct sonode *, int);
/* TPI sockfs sonode operations */
-int sotpi_init(struct sonode *, struct sonode *, struct cred *,
+int sotpi_init(struct sonode *, struct sonode *, struct cred *,
int);
static int sotpi_accept(struct sonode *, int, struct cred *,
struct sonode **);
@@ -230,16 +230,16 @@ extern int sotpi_getsockopt(struct sonode *, int, int, void *,
socklen_t *, int, struct cred *);
extern int sotpi_setsockopt(struct sonode *, int, int, const void *,
socklen_t, struct cred *);
-static int sotpi_ioctl(struct sonode *, int, intptr_t, int, struct cred *,
+static int sotpi_ioctl(struct sonode *, int, intptr_t, int, struct cred *,
int32_t *);
-static int socktpi_plumbioctl(struct vnode *, int, intptr_t, int,
+static int socktpi_plumbioctl(struct vnode *, int, intptr_t, int,
struct cred *, int32_t *);
-static int sotpi_poll(struct sonode *, short, int, short *,
+static int sotpi_poll(struct sonode *, short, int, short *,
struct pollhead **);
-static int sotpi_close(struct sonode *, int, struct cred *);
+static int sotpi_close(struct sonode *, int, struct cred *);
static int i_sotpi_info_constructor(sotpi_info_t *);
-static void i_sotpi_info_destructor(sotpi_info_t *);
+static void i_sotpi_info_destructor(sotpi_info_t *);
sonodeops_t sotpi_sonodeops = {
sotpi_init, /* sop_init */
@@ -279,7 +279,7 @@ sotpi_create(struct sockparams *sp, int family, int type, int protocol,
int version, int sflags, int *errorp, cred_t *cr)
{
struct sonode *so;
- kmem_cache_t *cp;
+ kmem_cache_t *cp;
int sfamily = family;
ASSERT(sp->sp_sdev_info.sd_vnode != NULL);
@@ -6109,7 +6109,7 @@ sotpi_ioctl(struct sonode *so, int cmd, intptr_t arg, int mode,
#ifdef DEBUG
zcmn_err(getzoneid(), CE_WARN,
"Unsupported STREAMS ioctl 0x%x on socket. "
- "Pid = %d\n", cmd, curproc->p_pid);
+ "Pid = %d\n", cmd, curproc->p_pid);
#endif /* DEBUG */
return (EOPNOTSUPP);
}
@@ -6201,7 +6201,7 @@ socktpi_plumbioctl(struct vnode *vp, int cmd, intptr_t arg, int mode,
STRUCT_DECL(str_list, ustrlist);
STRUCT_INIT(ustrlist, mode);
- if (arg == NULL) {
+ if (arg == 0) {
error = strioctl(vp, cmd, arg, mode, U_TO_K, cr, rvalp);
if (error == 0)
(*rvalp)++; /* Add one for sockmod */
@@ -6799,7 +6799,7 @@ sotpi_info_init(struct sonode *so)
sotpi_info_t *sti = SOTOTPI(so);
time_t now;
- sti->sti_dev = so->so_sockparams->sp_sdev_info.sd_vnode->v_rdev;
+ sti->sti_dev = so->so_sockparams->sp_sdev_info.sd_vnode->v_rdev;
vp->v_rdev = sti->sti_dev;
sti->sti_orig_sp = NULL;