1236.   [bug]           dns_rdata{class,type}_fromtext() didn't handle non
                        NULL terminated text regions. [RT #2588]
This commit is contained in:
Mark Andrews 2002-03-20 22:41:58 +00:00
parent 7f855bbeee
commit 1cf32ab2b3
3 changed files with 31 additions and 14 deletions

View file

@ -1,3 +1,6 @@
1236. [bug] dns_rdata{class,type}_fromtext() didn't handle non
NULL terminated text regions. [RT #2588]
1232. [bug] unix/errno2result() didn't handle EADDRNOTAVAIL.
1231. [port] HPUX 11.11 recvmsg() can return spurious EADDRNOTAVAIL.

View file

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: gen.c,v 1.65 2001/08/08 22:54:39 gson Exp $ */
/* $Id: gen.c,v 1.65.2.1 2002/03/20 22:41:57 marka Exp $ */
#include <config.h>
@ -666,9 +666,11 @@ main(int argc, char **argv) {
* Here, walk the list from top to bottom, calculating
* the hash (mod 256) for each name.
*/
fprintf(stdout, "#define RDATATYPE_COMPARE(_s, _d, _tn, _tp) \\\n");
fprintf(stdout, "#define RDATATYPE_COMPARE(_s, _d, _tn, _n, _tp) \\\n");
fprintf(stdout, "\tdo { \\\n");
fprintf(stdout, "\t\tif (strcasecmp(_s,(_tn)) == 0) { \\\n");
fprintf(stdout, "\t\tif (sizeof(_s) - 1 == _n && \\\n"
"\t\t strncasecmp(_s,(_tn),"
"(sizeof(_s) - 1)) == 0) { \\\n");
fprintf(stdout, "\t\t\tif ((typeattr[_d].flags & "
"DNS_RDATATYPEATTR_RESERVED) != 0) \\\n");
fprintf(stdout, "\t\t\t\treturn (ISC_R_NOTIMPLEMENTED); \\\n");
@ -677,8 +679,8 @@ main(int argc, char **argv) {
fprintf(stdout, "\t\t} \\\n");
fprintf(stdout, "\t} while (0)\n\n");
fprintf(stdout, "#define RDATATYPE_FROMTEXT_SW(_hash,_typename,_typep) "
"\\\n");
fprintf(stdout, "#define RDATATYPE_FROMTEXT_SW(_hash,"
"_typename,_length,_typep) \\\n");
fprintf(stdout, "\tswitch (_hash) { \\\n");
for (i = 0 ; i <= 255 ; i++) {
ttn = &typenames[i];
@ -703,7 +705,7 @@ main(int argc, char **argv) {
if (hash == HASH(ttn2->typename)) {
fprintf(stdout, "\t\t\tRDATATYPE_COMPARE"
"(\"%s\", %u, "
"_typename, _typep); \\\n",
"_typename, _length, _typep); \\\n",
ttn2->typename, j);
ttn2->sorted = 1;
}

View file

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: rdata.c,v 1.147.2.5 2002/02/20 02:17:24 marka Exp $ */
/* $Id: rdata.c,v 1.147.2.6 2002/03/20 22:41:58 marka Exp $ */
#include <config.h>
#include <ctype.h>
@ -1028,7 +1028,7 @@ isc_result_t
dns_rdataclass_fromtext(dns_rdataclass_t *classp, isc_textregion_t *source) {
#define COMPARE(string, rdclass) \
if (((sizeof(string) - 1) == source->length) \
&& (strcasecmp(source->base, string) == 0)) { \
&& (strncasecmp(source->base, string, source->length) == 0)) { \
*classp = rdclass; \
return (ISC_R_SUCCESS); \
}
@ -1045,11 +1045,17 @@ dns_rdataclass_fromtext(dns_rdataclass_t *classp, isc_textregion_t *source) {
*/
COMPARE("ch", dns_rdataclass_chaos);
COMPARE("chaos", dns_rdataclass_chaos);
if (source->length > 5 &&
strncasecmp("class", source->base, 5) == 0)
{
source->length < (5 + sizeof("65000")) &&
strncasecmp("class", source->base, 5) == 0) {
char buf[sizeof("65000")];
char *endp;
int val = strtol(source->base + 5, &endp, 10);
int val;
strncpy(buf, source->base + 5, sizeof(buf));
buf[sizeof(buf) - 1] = '\0';
val = strtol(buf, &endp, 10);
if (*endp == '\0' && val >= 0 && val <= 0xffff) {
*classp = (dns_rdataclass_t)val;
return (ISC_R_SUCCESS);
@ -1144,11 +1150,17 @@ dns_rdatatype_fromtext(dns_rdatatype_t *typep, isc_textregion_t *source) {
* to return a result to the caller if it is a valid (known)
* rdatatype name.
*/
RDATATYPE_FROMTEXT_SW(hash, source->base, typep);
RDATATYPE_FROMTEXT_SW(hash, source->base, n, typep);
if (source->length > 4 && strncasecmp("type", source->base, 4) == 0) {
if (source->length > 4 && source->length < (4 + sizeof("65000")) &&
strncasecmp("type", source->base, 4) == 0) {
char buf[sizeof("65000")];
char *endp;
int val = strtol(source->base + 4, &endp, 10);
int val;
strncpy(buf, source->base + 4, sizeof(buf));
buf[sizeof(buf) - 1] = '\0';
val = strtol(buf, &endp, 10);
if (*endp == '\0' && val >= 0 && val <= 0xffff) {
*typep = (dns_rdatatype_t)val;
return (ISC_R_SUCCESS);