summaryrefslogtreecommitdiffstats
path: root/contrib/isc-dhcp/minires
diff options
context:
space:
mode:
authormurray <murray@FreeBSD.org>2002-04-01 07:54:44 +0000
committermurray <murray@FreeBSD.org>2002-04-01 07:54:44 +0000
commita916d35e05e0f886097009e26d33c65a1ea5c370 (patch)
treedc453635e10392b086bc6d179ba3e703cf584ce2 /contrib/isc-dhcp/minires
parent57b30d23e7c11fa1a8c8c23f27de40971872952f (diff)
downloadFreeBSD-src-a916d35e05e0f886097009e26d33c65a1ea5c370.zip
FreeBSD-src-a916d35e05e0f886097009e26d33c65a1ea5c370.tar.gz
Import ISC DHCP 3.0.1 RC8 client.
Diffstat (limited to 'contrib/isc-dhcp/minires')
-rw-r--r--contrib/isc-dhcp/minires/ns_parse.c60
-rw-r--r--contrib/isc-dhcp/minires/ns_verify.c19
2 files changed, 42 insertions, 37 deletions
diff --git a/contrib/isc-dhcp/minires/ns_parse.c b/contrib/isc-dhcp/minires/ns_parse.c
index 27b06a1..cc4d98e 100644
--- a/contrib/isc-dhcp/minires/ns_parse.c
+++ b/contrib/isc-dhcp/minires/ns_parse.c
@@ -16,7 +16,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$Id: ns_parse.c,v 1.2 2001/01/16 22:33:08 mellon Exp $";
+static const char rcsid[] = "$Id: ns_parse.c,v 1.2.2.1 2002/02/19 19:16:52 mellon Exp $";
#endif
/* Import. */
@@ -38,8 +38,6 @@ static void setsection(ns_msg *msg, ns_sect sect);
/* Macros. */
-#define RETERR(err) do { errno = (err); return (-1); } while (0)
-
/* Public. */
/* These need to be in the same order as the nres.h:ns_flag enum. */
@@ -62,8 +60,9 @@ struct _ns_flagdata _ns_flagdata[16] = {
{ 0x0000, 0 }, /* expansion (6/6). */
};
-int
-ns_skiprr(const u_char *ptr, const u_char *eom, ns_sect section, int count) {
+isc_result_t
+ns_skiprr(const u_char *ptr, const u_char *eom, ns_sect section, int count,
+ int *rc) {
const u_char *optr = ptr;
for ((void)NULL; count > 0; count--) {
@@ -71,11 +70,11 @@ ns_skiprr(const u_char *ptr, const u_char *eom, ns_sect section, int count) {
b = dn_skipname(ptr, eom);
if (b < 0)
- RETERR(EMSGSIZE);
+ return ISC_R_INCOMPLETE;
ptr += b/*Name*/ + NS_INT16SZ/*Type*/ + NS_INT16SZ/*Class*/;
if (section != ns_s_qd) {
if (ptr + NS_INT32SZ + NS_INT16SZ > eom)
- RETERR(EMSGSIZE);
+ return ISC_R_INCOMPLETE;
ptr += NS_INT32SZ/*TTL*/;
rdlength = getUShort(ptr);
ptr += 2;
@@ -83,11 +82,13 @@ ns_skiprr(const u_char *ptr, const u_char *eom, ns_sect section, int count) {
}
}
if (ptr > eom)
- RETERR(EMSGSIZE);
- return (ptr - optr);
+ return ISC_R_INCOMPLETE;
+ if (rc)
+ *rc = ptr - optr;
+ return ISC_R_SUCCESS;
}
-int
+isc_result_t
ns_initparse(const u_char *msg, unsigned msglen, ns_msg *handle) {
const u_char *eom = msg + msglen;
int i;
@@ -96,16 +97,16 @@ ns_initparse(const u_char *msg, unsigned msglen, ns_msg *handle) {
handle->_msg = msg;
handle->_eom = eom;
if (msg + NS_INT16SZ > eom)
- RETERR(EMSGSIZE);
+ return ISC_R_INCOMPLETE;
handle->_id = getUShort (msg);
msg += 2;
if (msg + NS_INT16SZ > eom)
- RETERR(EMSGSIZE);
+ return ISC_R_INCOMPLETE;
handle->_flags = getUShort (msg);
msg += 2;
for (i = 0; i < ns_s_max; i++) {
if (msg + NS_INT16SZ > eom)
- RETERR(EMSGSIZE);
+ return ISC_R_INCOMPLETE;
handle->_counts[i] = getUShort (msg);
msg += 2;
}
@@ -113,23 +114,26 @@ ns_initparse(const u_char *msg, unsigned msglen, ns_msg *handle) {
if (handle->_counts[i] == 0)
handle->_sections[i] = NULL;
else {
- int b = ns_skiprr(msg, eom, (ns_sect)i,
- handle->_counts[i]);
+ int b;
+ isc_result_t status =
+ ns_skiprr(msg, eom, (ns_sect)i,
+ handle->_counts[i], &b);
- if (b < 0)
- return (-1);
+ if (status != ISC_R_SUCCESS)
+ return STATUS;
handle->_sections[i] = msg;
msg += b;
}
if (msg != eom)
- RETERR(EMSGSIZE);
+ return ISC_R_INCOMPLETE;
setsection(handle, ns_s_max);
- return (0);
+ return ISC_R_SUCCESS;
}
isc_result_t
ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) {
int b;
+ isc_result_t status;
/* Make section right. */
if (section < 0 || section >= ns_s_max)
@@ -141,15 +145,15 @@ ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) {
if (rrnum == -1)
rrnum = handle->_rrnum;
if (rrnum < 0 || rrnum >= handle->_counts[(int)section])
- RETERR(ENODEV);
+ return ISC_R_UNKNOWNATTRIBUTE;
if (rrnum < handle->_rrnum)
setsection(handle, section);
if (rrnum > handle->_rrnum) {
- b = ns_skiprr(handle->_ptr, handle->_eom, section,
- rrnum - handle->_rrnum);
+ status = ns_skiprr(handle->_ptr, handle->_eom, section,
+ rrnum - handle->_rrnum, &b);
- if (b < 0)
- return (-1);
+ if (status != ISC_R_SUCCESS)
+ return status;
handle->_ptr += b;
handle->_rrnum = rrnum;
}
@@ -158,10 +162,10 @@ ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) {
b = dn_expand(handle->_msg, handle->_eom,
handle->_ptr, rr->name, NS_MAXDNAME);
if (b < 0)
- return (-1);
+ return ISC_R_FORMERR;
handle->_ptr += b;
if (handle->_ptr + NS_INT16SZ + NS_INT16SZ > handle->_eom)
- return ISC_R_NOSPACE;
+ return ISC_R_INCOMPLETE;
rr->type = getUShort (handle->_ptr);
handle -> _ptr += 2;
rr->rr_class = getUShort (handle->_ptr);
@@ -172,13 +176,13 @@ ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) {
rr->rdata = NULL;
} else {
if (handle->_ptr + NS_INT32SZ + NS_INT16SZ > handle->_eom)
- return ISC_R_NOSPACE;
+ return ISC_R_INCOMPLETE;
rr->ttl = getULong (handle->_ptr);
handle -> _ptr += 4;
rr->rdlength = getUShort (handle->_ptr);
handle -> _ptr += 2;
if (handle->_ptr + rr->rdlength > handle->_eom)
- return ISC_R_NOSPACE;
+ return ISC_R_INCOMPLETE;
rr->rdata = handle->_ptr;
handle->_ptr += rr->rdlength;
}
diff --git a/contrib/isc-dhcp/minires/ns_verify.c b/contrib/isc-dhcp/minires/ns_verify.c
index 1408da6..306226c 100644
--- a/contrib/isc-dhcp/minires/ns_verify.c
+++ b/contrib/isc-dhcp/minires/ns_verify.c
@@ -16,7 +16,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$Id: ns_verify.c,v 1.5.2.1 2001/05/17 20:47:34 mellon Exp $";
+static const char rcsid[] = "$Id: ns_verify.c,v 1.5.2.2 2002/02/19 19:23:31 mellon Exp $";
#endif
#define time(x) trace_mr_time (x)
@@ -60,6 +60,7 @@ ns_find_tsig(u_char *msg, u_char *eom) {
HEADER *hp = (HEADER *)msg;
int n, type;
u_char *cp = msg, *start;
+ isc_result_t status;
if (msg == NULL || eom == NULL || msg > eom)
return (NULL);
@@ -72,23 +73,23 @@ ns_find_tsig(u_char *msg, u_char *eom) {
cp += HFIXEDSZ;
- n = ns_skiprr(cp, eom, ns_s_qd, ntohs(hp->qdcount));
- if (n < 0)
+ status = ns_skiprr(cp, eom, ns_s_qd, ntohs(hp->qdcount), &n);
+ if (status != ISC_R_SUCCESS)
return (NULL);
cp += n;
- n = ns_skiprr(cp, eom, ns_s_an, ntohs(hp->ancount));
- if (n < 0)
+ status = ns_skiprr(cp, eom, ns_s_an, ntohs(hp->ancount), &n);
+ if (status != ISC_R_SUCCESS)
return (NULL);
cp += n;
- n = ns_skiprr(cp, eom, ns_s_ns, ntohs(hp->nscount));
- if (n < 0)
+ status = ns_skiprr(cp, eom, ns_s_ns, ntohs(hp->nscount), &n);
+ if (status != ISC_R_SUCCESS)
return (NULL);
cp += n;
- n = ns_skiprr(cp, eom, ns_s_ar, ntohs(hp->arcount) - 1);
- if (n < 0)
+ status = ns_skiprr(cp, eom, ns_s_ar, ntohs(hp->arcount) - 1, &n);
+ if (status != ISC_R_SUCCESS)
return (NULL);
cp += n;
OpenPOWER on IntegriCloud