aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2002-10-22 18:44:59 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2002-10-22 18:44:59 +0000
commit12f65109c85866874b24d136a9605fa091fddb91 (patch)
tree1034b44c94dfc283e537caf97cbf0f3f7ceb42f6
parent11f0df9ed082bd238609811beba9514ae1ecb215 (diff)
downloadsrc-12f65109c85866874b24d136a9605fa091fddb91.tar.gz
src-12f65109c85866874b24d136a9605fa091fddb91.zip
Don't dereference the 'x' pointer if it is NULL, instead skip the
assignment. The netsmb code likes to call these functions with a NULL x argument a lot. Reported by: Vallo Kallaste <kalts@estpak.ee>
Notes
Notes: svn path=/head/; revision=105735
-rw-r--r--sys/kern/subr_mchain.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/sys/kern/subr_mchain.c b/sys/kern/subr_mchain.c
index cb15ff7c1f16..b63a12e865f6 100644
--- a/sys/kern/subr_mchain.c
+++ b/sys/kern/subr_mchain.c
@@ -376,7 +376,8 @@ md_get_uint16le(struct mdchain *mdp, u_int16_t *x)
u_int16_t v;
int error = md_get_uint16(mdp, &v);
- *x = letohs(v);
+ if (x != NULL)
+ *x = letohs(v);
return error;
}
@@ -385,7 +386,8 @@ md_get_uint16be(struct mdchain *mdp, u_int16_t *x) {
u_int16_t v;
int error = md_get_uint16(mdp, &v);
- *x = betohs(v);
+ if (x != NULL)
+ *x = betohs(v);
return error;
}
@@ -402,7 +404,8 @@ md_get_uint32be(struct mdchain *mdp, u_int32_t *x)
int error;
error = md_get_uint32(mdp, &v);
- *x = betohl(v);
+ if (x != NULL)
+ *x = betohl(v);
return error;
}
@@ -413,7 +416,8 @@ md_get_uint32le(struct mdchain *mdp, u_int32_t *x)
int error;
error = md_get_uint32(mdp, &v);
- *x = letohl(v);
+ if (x != NULL)
+ *x = letohl(v);
return error;
}
@@ -430,7 +434,8 @@ md_get_int64be(struct mdchain *mdp, int64_t *x)
int error;
error = md_get_int64(mdp, &v);
- *x = betohq(v);
+ if (x != NULL)
+ *x = betohq(v);
return error;
}
@@ -441,7 +446,8 @@ md_get_int64le(struct mdchain *mdp, int64_t *x)
int error;
error = md_get_int64(mdp, &v);
- *x = letohq(v);
+ if (x != NULL)
+ *x = letohq(v);
return error;
}