]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
add more check rt46281
authorMark Andrews <marka@isc.org>
Sat, 14 Oct 2017 21:49:22 +0000 (08:49 +1100)
committerMark Andrews <marka@isc.org>
Sat, 14 Oct 2017 21:49:22 +0000 (08:49 +1100)
lib/isc/tests/mem_test.c

index 343672f54846c3547b2d68c3f0632dc54138af18..0184d685768aae2661cbb12ed2d4d33a9b396d49 100644 (file)
@@ -155,7 +155,6 @@ ATF_TC_BODY(isc_mem_noflags, tc) {
        char buf[4096], *p, *q;
        FILE *f;
        void *ptr;
-       size_t size;
 
        result = isc_stdio_open("mem.output", "w", &f);
        ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
@@ -174,22 +173,27 @@ ATF_TC_BODY(isc_mem_noflags, tc) {
        isc_mem_destroy(&mctx2);
        isc_stdio_close(f);
 
+       memset(buf, 0, sizeof(buf));
        result = isc_stdio_open("mem.output", "r", &f);
        ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
-       result = isc_stdio_read(buf, sizeof(buf), 1, f, &size);
+       result = isc_stdio_read(buf, sizeof(buf), 1, f, NULL);
        ATF_REQUIRE_EQ(result, ISC_R_EOF);
        isc_stdio_close(f);
        isc_file_remove("mem.output");
 
+       buf[sizeof(buf) - 1] = 0;
+
        p = strchr(buf, '\n');
+       ATF_REQUIRE(p != NULL);
+       ATF_REQUIRE(p < buf + sizeof(buf) - 2);
        p += 2;
        q = strchr(p, '\n');
+       ATF_REQUIRE(q != NULL);
        *q = '\0';
        ATF_CHECK_STREQ(p, "None.");
 
        isc_mem_debugging = ISC_MEM_DEBUGRECORD;
        isc_test_end();
-
 }
 
 ATF_TC(isc_mem_recordflag);
@@ -203,7 +207,6 @@ ATF_TC_BODY(isc_mem_recordflag, tc) {
        char buf[4096], *p;
        FILE *f;
        void *ptr;
-       size_t size;
 
        result = isc_stdio_open("mem.output", "w", &f);
        ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
@@ -224,14 +227,19 @@ ATF_TC_BODY(isc_mem_recordflag, tc) {
        memset(buf, 0, sizeof(buf));
        result = isc_stdio_open("mem.output", "r", &f);
        ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
-       result = isc_stdio_read(buf, sizeof(buf), 1, f, &size);
+       result = isc_stdio_read(buf, sizeof(buf), 1, f, NULL);
        ATF_REQUIRE_EQ(result, ISC_R_EOF);
        isc_stdio_close(f);
        isc_file_remove("mem.output");
 
+       buf[sizeof(buf) - 1] = 0;
+
        p = strchr(buf, '\n');
+       ATF_REQUIRE(p != NULL);
+       ATF_REQUIRE(p < buf + sizeof(buf) - 2);
        ATF_CHECK(strncmp(p + 2, "ptr ", 4) == 0);
        p = strchr(p + 1, '\n');
+       ATF_REQUIRE(p != NULL);
        ATF_CHECK(strlen(p) == 1);
 
        isc_test_end();
@@ -267,9 +275,9 @@ ATF_TC_BODY(isc_mem_traceflag, tc) {
        isc_mem_destroy(&mctx2);
        isc_stdio_close(f);
 
+       memset(buf, 0, sizeof(buf));
        result = isc_stdio_open("mem.output", "r", &f);
        ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
-       memset(buf, 0, sizeof(buf));
        result = isc_stdio_read(buf, sizeof(buf), 1, f, NULL);
        ATF_REQUIRE_EQ(result, ISC_R_EOF);
        isc_stdio_close(f);
@@ -285,6 +293,7 @@ ATF_TC_BODY(isc_mem_traceflag, tc) {
        ATF_REQUIRE(p != NULL);
        p = strchr(p + 1, '\n');
        ATF_REQUIRE(p != NULL);
+       ATF_REQUIRE(p < buf + sizeof(buf) - 2);
        ATF_CHECK(strncmp(p + 2, "ptr ", 4) == 0);
        p = strchr(p + 1, '\n');
        ATF_REQUIRE(p != NULL);