mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-03 08:05:21 +00:00
3668. [bug] Fix cast in lex.c which could see 0xff treated as eof.
[RT #34993]
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -1,3 +1,6 @@
|
|||||||
|
3668. [bug] Fix cast in lex.c which could see 0xff treated as eof.
|
||||||
|
[RT #34993]
|
||||||
|
|
||||||
3667. [func] dig: add support to keep the TCP socket open between
|
3667. [func] dig: add support to keep the TCP socket open between
|
||||||
successive queries (+[no]keepopen). [RT #34918]
|
successive queries (+[no]keepopen). [RT #34918]
|
||||||
|
|
||||||
|
@@ -445,7 +445,7 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) {
|
|||||||
c = EOF;
|
c = EOF;
|
||||||
source->at_eof = ISC_TRUE;
|
source->at_eof = ISC_TRUE;
|
||||||
} else {
|
} else {
|
||||||
c = *((char *)buffer->base +
|
c = *((unsigned char *)buffer->base +
|
||||||
buffer->current);
|
buffer->current);
|
||||||
buffer->current++;
|
buffer->current++;
|
||||||
}
|
}
|
||||||
|
@@ -36,12 +36,14 @@ LIBS = @LIBS@ @ATFLIBS@
|
|||||||
|
|
||||||
OBJS = isctest.@O@
|
OBJS = isctest.@O@
|
||||||
SRCS = isctest.c taskpool_test.c socket_test.c hash_test.c \
|
SRCS = isctest.c taskpool_test.c socket_test.c hash_test.c \
|
||||||
|
lex_test.c \
|
||||||
sockaddr_test.c symtab_test.c task_test.c queue_test.c \
|
sockaddr_test.c symtab_test.c task_test.c queue_test.c \
|
||||||
parse_test.c pool_test.c regex_test.c socket_test.c \
|
parse_test.c pool_test.c regex_test.c socket_test.c \
|
||||||
safe_test.c
|
safe_test.c
|
||||||
|
|
||||||
SUBDIRS =
|
SUBDIRS =
|
||||||
TARGETS = taskpool_test@EXEEXT@ socket_test@EXEEXT@ hash_test@EXEEXT@ \
|
TARGETS = taskpool_test@EXEEXT@ socket_test@EXEEXT@ hash_test@EXEEXT@ \
|
||||||
|
lex_test@EXEEXT@ \
|
||||||
sockaddr_test@EXEEXT@ symtab_test@EXEEXT@ task_test@EXEEXT@ \
|
sockaddr_test@EXEEXT@ symtab_test@EXEEXT@ task_test@EXEEXT@ \
|
||||||
queue_test@EXEEXT@ parse_test@EXEEXT@ pool_test@EXEEXT@ \
|
queue_test@EXEEXT@ parse_test@EXEEXT@ pool_test@EXEEXT@ \
|
||||||
regex_test@EXEEXT@ socket_test@EXEEXT@ safe_test@EXEEXT@
|
regex_test@EXEEXT@ socket_test@EXEEXT@ safe_test@EXEEXT@
|
||||||
@@ -64,6 +66,10 @@ hash_test@EXEEXT@: hash_test.@O@ ${ISCDEPLIBS}
|
|||||||
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
|
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
|
||||||
hash_test.@O@ ${ISCLIBS} ${LIBS}
|
hash_test.@O@ ${ISCLIBS} ${LIBS}
|
||||||
|
|
||||||
|
lex_test@EXEEXT@: lex_test.@O@ ${ISCDEPLIBS}
|
||||||
|
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
|
||||||
|
lex_test.@O@ ${ISCLIBS} ${LIBS}
|
||||||
|
|
||||||
queue_test@EXEEXT@: queue_test.@O@ isctest.@O@ ${ISCDEPLIBS}
|
queue_test@EXEEXT@: queue_test.@O@ isctest.@O@ ${ISCDEPLIBS}
|
||||||
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
|
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
|
||||||
queue_test.@O@ isctest.@O@ ${ISCLIBS} ${LIBS}
|
queue_test.@O@ isctest.@O@ ${ISCLIBS} ${LIBS}
|
||||||
|
69
lib/isc/tests/lex_test.c
Normal file
69
lib/isc/tests/lex_test.c
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||||
|
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
* PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <atf-c.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <isc/buffer.h>
|
||||||
|
#include <isc/lex.h>
|
||||||
|
#include <isc/mem.h>
|
||||||
|
#include <isc/util.h>
|
||||||
|
|
||||||
|
ATF_TC(lex);
|
||||||
|
ATF_TC_HEAD(lex, tc) {
|
||||||
|
atf_tc_set_md_var(tc, "descr", "check handling of 0xff");
|
||||||
|
}
|
||||||
|
ATF_TC_BODY(lex, tc) {
|
||||||
|
isc_mem_t *mctx = NULL;
|
||||||
|
isc_result_t result;
|
||||||
|
isc_lex_t *lex = NULL;
|
||||||
|
isc_buffer_t death_buf;
|
||||||
|
isc_token_t token;
|
||||||
|
|
||||||
|
unsigned char death[] = { EOF, 'A' };
|
||||||
|
|
||||||
|
UNUSED(tc);
|
||||||
|
|
||||||
|
result = isc_mem_create(0, 0, &mctx);
|
||||||
|
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
|
result = isc_lex_create(mctx, 1024, &lex);
|
||||||
|
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
|
isc_buffer_init(&death_buf, &death[0], sizeof(death));
|
||||||
|
isc_buffer_add(&death_buf, sizeof(death));
|
||||||
|
|
||||||
|
result = isc_lex_openbuffer(lex, &death_buf);
|
||||||
|
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
|
result = isc_lex_gettoken(lex, 0, &token);
|
||||||
|
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Main
|
||||||
|
*/
|
||||||
|
ATF_TP_ADD_TCS(tp) {
|
||||||
|
ATF_TP_ADD_TC(tp, lex);
|
||||||
|
return (atf_no_error());
|
||||||
|
}
|
||||||
|
|
Reference in New Issue
Block a user