mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-04 08:35:31 +00:00
Added new error code DNS_R_UNEXPECTEDTOKEN, DNS_R_BADBASE64.
Adjusted function to use the new error codes. Changed some INSIST -> REQUIRE. Mapped ISC_R_NOMEMORY -> DNS_R_NOMEMORY for isc_lex_gettoken() result.
This commit is contained in:
@@ -49,8 +49,10 @@ typedef unsigned int dns_result_t;
|
|||||||
#define DNS_R_NOOWNER 26
|
#define DNS_R_NOOWNER 26
|
||||||
#define DNS_R_NOTTL 27
|
#define DNS_R_NOTTL 27
|
||||||
#define DNS_R_BADCLASS 28
|
#define DNS_R_BADCLASS 28
|
||||||
|
#define DNS_R_UNEXPECTEDTOKEN 29
|
||||||
|
#define DNS_R_BADBASE64 30
|
||||||
|
|
||||||
#define DNS_R_LASTENTRY 28 /* Last entry on list. */
|
#define DNS_R_LASTENTRY 30 /* Last entry on list. */
|
||||||
|
|
||||||
#define DNS_R_UNEXPECTED 0xFFFFFFFFL
|
#define DNS_R_UNEXPECTED 0xFFFFFFFFL
|
||||||
|
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: rdata.c,v 1.32 1999/02/10 05:25:37 marka Exp $ */
|
/* $Id: rdata.c,v 1.33 1999/02/12 03:08:44 marka Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@@ -345,6 +345,9 @@ dns_rdata_fromtext(dns_rdata_t *rdata,
|
|||||||
if (iresult != ISC_R_SUCCESS) {
|
if (iresult != ISC_R_SUCCESS) {
|
||||||
if (result == DNS_R_SUCCESS) {
|
if (result == DNS_R_SUCCESS) {
|
||||||
switch (iresult) {
|
switch (iresult) {
|
||||||
|
case ISC_R_NOMEMORY:
|
||||||
|
result = DNS_R_NOMEMORY;
|
||||||
|
break;
|
||||||
case ISC_R_NOSPACE:
|
case ISC_R_NOSPACE:
|
||||||
result = DNS_R_NOSPACE;
|
result = DNS_R_NOSPACE;
|
||||||
break;
|
break;
|
||||||
@@ -785,7 +788,7 @@ static isc_uint32_t
|
|||||||
uint32_fromregion(isc_region_t *region) {
|
uint32_fromregion(isc_region_t *region) {
|
||||||
unsigned long value;
|
unsigned long value;
|
||||||
|
|
||||||
INSIST(region->length >= 4);
|
REQUIRE(region->length >= 4);
|
||||||
value = region->base[0] << 24;
|
value = region->base[0] << 24;
|
||||||
value |= region->base[1] << 16;
|
value |= region->base[1] << 16;
|
||||||
value |= region->base[2] << 8;
|
value |= region->base[2] << 8;
|
||||||
@@ -796,7 +799,7 @@ uint32_fromregion(isc_region_t *region) {
|
|||||||
static isc_uint16_t
|
static isc_uint16_t
|
||||||
uint16_fromregion(isc_region_t *region) {
|
uint16_fromregion(isc_region_t *region) {
|
||||||
|
|
||||||
INSIST(region->length >= 2);
|
REQUIRE(region->length >= 2);
|
||||||
|
|
||||||
return ((region->base[0] << 8) | region->base[1]);
|
return ((region->base[0] << 8) | region->base[1]);
|
||||||
}
|
}
|
||||||
@@ -816,6 +819,8 @@ gettoken(isc_lex_t *lexer, isc_token_t *token, isc_tokentype_t expect,
|
|||||||
switch (result) {
|
switch (result) {
|
||||||
case ISC_R_SUCCESS:
|
case ISC_R_SUCCESS:
|
||||||
break;
|
break;
|
||||||
|
case ISC_R_NOMEMORY:
|
||||||
|
return (DNS_R_NOMEMORY);
|
||||||
case ISC_R_NOSPACE:
|
case ISC_R_NOSPACE:
|
||||||
return (DNS_R_NOSPACE);
|
return (DNS_R_NOSPACE);
|
||||||
default:
|
default:
|
||||||
@@ -835,9 +840,7 @@ gettoken(isc_lex_t *lexer, isc_token_t *token, isc_tokentype_t expect,
|
|||||||
if (token->type == isc_tokentype_eol ||
|
if (token->type == isc_tokentype_eol ||
|
||||||
token->type == isc_tokentype_eof)
|
token->type == isc_tokentype_eof)
|
||||||
return (DNS_R_UNEXPECTEDEND);
|
return (DNS_R_UNEXPECTEDEND);
|
||||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
return (DNS_R_UNEXPECTEDTOKEN);
|
||||||
"isc_lex_gettoken() returned unexpected token type\n");
|
|
||||||
return (DNS_R_UNEXPECTED);
|
|
||||||
}
|
}
|
||||||
return (DNS_R_SUCCESS);
|
return (DNS_R_SUCCESS);
|
||||||
}
|
}
|
||||||
@@ -956,15 +959,15 @@ base64_tobuffer(isc_lex_t *lexer, isc_buffer_t *target, int length) {
|
|||||||
tr = &token.value.as_textregion;
|
tr = &token.value.as_textregion;
|
||||||
for (i = 0 ;i < tr->length; i++) {
|
for (i = 0 ;i < tr->length; i++) {
|
||||||
if (seen_end)
|
if (seen_end)
|
||||||
return (DNS_R_SYNTAX);
|
return (DNS_R_BADBASE64);
|
||||||
if ((s = strchr(base64, tr->base[i])) == NULL)
|
if ((s = strchr(base64, tr->base[i])) == NULL)
|
||||||
return (DNS_R_SYNTAX);
|
return (DNS_R_BADBASE64);
|
||||||
val[digits++] = s - base64;
|
val[digits++] = s - base64;
|
||||||
if (digits == 4) {
|
if (digits == 4) {
|
||||||
if (val[0] == 64 || val[1] == 64)
|
if (val[0] == 64 || val[1] == 64)
|
||||||
return (DNS_R_SYNTAX);
|
return (DNS_R_BADBASE64);
|
||||||
if (val[2] == 64 && val[3] != 64)
|
if (val[2] == 64 && val[3] != 64)
|
||||||
return (DNS_R_SYNTAX);
|
return (DNS_R_BADBASE64);
|
||||||
n = (val[2] == 64) ? 1 :
|
n = (val[2] == 64) ? 1 :
|
||||||
(val[3] == 64) ? 2 : 3;
|
(val[3] == 64) ? 2 : 3;
|
||||||
if (n != 3) {
|
if (n != 3) {
|
||||||
@@ -980,7 +983,7 @@ base64_tobuffer(isc_lex_t *lexer, isc_buffer_t *target, int length) {
|
|||||||
RETERR(mem_tobuffer(target, buf, n));
|
RETERR(mem_tobuffer(target, buf, n));
|
||||||
if (length >= 0)
|
if (length >= 0)
|
||||||
if (n > length)
|
if (n > length)
|
||||||
return (DNS_R_SYNTAX);
|
return (DNS_R_BADBASE64);
|
||||||
else
|
else
|
||||||
length -= n;
|
length -= n;
|
||||||
digits = 0;
|
digits = 0;
|
||||||
@@ -991,8 +994,8 @@ base64_tobuffer(isc_lex_t *lexer, isc_buffer_t *target, int length) {
|
|||||||
isc_lex_ungettoken(lexer, &token);
|
isc_lex_ungettoken(lexer, &token);
|
||||||
if (length > 0)
|
if (length > 0)
|
||||||
return (DNS_R_UNEXPECTEDEND);
|
return (DNS_R_UNEXPECTEDEND);
|
||||||
if (digits)
|
if (digits != 0)
|
||||||
return (DNS_R_SYNTAX);
|
return (DNS_R_BADBASE64);
|
||||||
return (DNS_R_SUCCESS);
|
return (DNS_R_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -46,9 +46,11 @@ static char *text_table[DNS_R_LASTENTRY + 1] = {
|
|||||||
"syntax error", /* 23 */
|
"syntax error", /* 23 */
|
||||||
"bad checksum", /* 24 */
|
"bad checksum", /* 24 */
|
||||||
"bad IPv6 address", /* 25 */
|
"bad IPv6 address", /* 25 */
|
||||||
"no owner" /* 26 */
|
"no owner", /* 26 */
|
||||||
"no ttl" /* 27 */
|
"no ttl", /* 27 */
|
||||||
"bad class" /* 28 */
|
"bad class", /* 28 */
|
||||||
|
"unexpected token", /* 29 */
|
||||||
|
"bad base64 encoding", /* 30 */
|
||||||
};
|
};
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
Reference in New Issue
Block a user