0 terminate xml files

This commit is contained in:
Willem Toorop 2017-07-01 00:45:09 +02:00
parent 2b20f35e0e
commit 59ff5e8178
3 changed files with 6 additions and 4 deletions

View File

@ -1118,7 +1118,8 @@ static void tas_read_cb(void *userarg)
} }
if (doc_len > 0) { if (doc_len > 0) {
uint8_t *doc = GETDNS_XMALLOC( uint8_t *doc = GETDNS_XMALLOC(
context->mf, uint8_t, doc_len); context->mf, uint8_t, doc_len + 1);
doc[doc_len] = 0;
DEBUG_ANCHOR("i: %d, n: %d, doc_len: %d\n" DEBUG_ANCHOR("i: %d, n: %d, doc_len: %d\n"
, (int)i, (int)n, doc_len); , (int)i, (int)n, doc_len);

View File

@ -4539,8 +4539,8 @@ uint8_t *_getdns_context_get_priv_file(getdns_context *context,
if (!(f = fopen(path, "r"))) if (!(f = fopen(path, "r")))
return NULL; return NULL;
if ((*file_sz = fread(buf, 1, buf_len, f)) < buf_len && feof(f)) if ((*file_sz = fread(buf, 1, buf_len, f)) < (buf_len - 1) && feof(f))
; /* pass */ buf[*file_sz] = 0;
else if (fseek(f, 0, SEEK_END) < 0) else if (fseek(f, 0, SEEK_END) < 0)
buf = NULL; buf = NULL;
@ -4553,6 +4553,7 @@ uint8_t *_getdns_context_get_priv_file(getdns_context *context,
GETDNS_FREE(context->mf, buf); GETDNS_FREE(context->mf, buf);
buf = NULL; buf = NULL;
} }
buf[*file_sz] = 0;
} }
(void) fclose(f); (void) fclose(f);
return buf; return buf;

View File

@ -25,4 +25,4 @@ done
rm -fr "${BUILDDIR}/build" rm -fr "${BUILDDIR}/build"
mkdir "${BUILDDIR}/build" mkdir "${BUILDDIR}/build"
cd "${BUILDDIR}/build" cd "${BUILDDIR}/build"
"${SRCROOT}/configure" $* --prefix "${BUILDDIR}/install" "${SRCROOT}/configure" $* --prefix "${BUILDDIR}/install" --enable-debug-anchor