2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

2453. [bug] Remove NULL pointer dereference in dns_journal_print().

[RT #18316]

2452.   [func]          Improve bin/test/journalprint. [RT #18316]
This commit is contained in:
Mark Andrews
2008-09-25 02:01:45 +00:00
parent 13fb52f8ff
commit 5737b74d34
3 changed files with 51 additions and 8 deletions

View File

@@ -1,3 +1,8 @@
2453. [bug] Remove NULL pointer dereference in dns_journal_print().
[RT #18316]
2452. [func] Improve bin/test/journalprint. [RT #18316]
2451. [port] solaris: handle runtime linking better. [RT #18356]
2450. [doc] Fix lwresd docbook problem for manual page.

View File

@@ -15,23 +15,57 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: journalprint.c,v 1.12 2007/06/18 23:47:26 tbox Exp $ */
/* $Id: journalprint.c,v 1.13 2008/09/25 02:01:45 marka Exp $ */
/*! \file */
#include <config.h>
#include <isc/log.h>
#include <isc/mem.h>
#include <isc/util.h>
#include <dns/journal.h>
#include <dns/log.h>
#include <dns/result.h>
#include <dns/types.h>
#include <stdlib.h>
/*
* Setup logging to use stderr.
*/
static isc_result_t
setup_logging(isc_mem_t *mctx, FILE *errout, isc_log_t **logp) {
isc_logdestination_t destination;
isc_logconfig_t *logconfig = NULL;
isc_log_t *log = NULL;
RUNTIME_CHECK(isc_log_create(mctx, &log, &logconfig) == ISC_R_SUCCESS);
isc_log_setcontext(log);
dns_log_init(log);
dns_log_setcontext(log);
destination.file.stream = errout;
destination.file.name = NULL;
destination.file.versions = ISC_LOG_ROLLNEVER;
destination.file.maximum_size = 0;
RUNTIME_CHECK(isc_log_createchannel(logconfig, "stderr",
ISC_LOG_TOFILEDESC,
ISC_LOG_DYNAMIC,
&destination, 0) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_log_usechannel(logconfig, "stderr",
NULL, NULL) == ISC_R_SUCCESS);
*logp = log;
return (ISC_R_SUCCESS);
}
int
main(int argc, char **argv) {
char *file;
isc_mem_t *mctx = NULL;
isc_result_t result;
isc_log_t *lctx = NULL;
if (argc != 2) {
printf("usage: %s journal\n", argv[0]);
@@ -41,8 +75,12 @@ main(int argc, char **argv) {
file = argv[1];
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
RUNTIME_CHECK(setup_logging(mctx, stderr, &lctx) == ISC_R_SUCCESS);
RUNTIME_CHECK(dns_journal_print(mctx, file, stdout) == ISC_R_SUCCESS);
result = dns_journal_print(mctx, file, stdout);
if (result == DNS_R_NOJOURNAL)
fprintf(stderr, "%s\n", dns_result_totext(result));
isc_log_destroy(&lctx);
isc_mem_detach(&mctx);
return(0);
return(result != ISC_R_SUCCESS ? 1 : 0);
}

View File

@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: journal.c,v 1.102 2008/09/24 02:46:22 marka Exp $ */
/* $Id: journal.c,v 1.103 2008/09/25 02:01:45 marka Exp $ */
#include <config.h>
@@ -1402,7 +1402,7 @@ dns_journal_print(isc_mem_t *mctx, const char *filename, FILE *file) {
if (result != ISC_R_SUCCESS) {
isc_log_write(JOURNAL_COMMON_LOGARGS, ISC_LOG_ERROR,
"journal open failure: %s: %s",
isc_result_totext(result), j->filename);
isc_result_totext(result), filename);
return (result);
}
@@ -1440,9 +1440,9 @@ dns_journal_print(isc_mem_t *mctx, const char *filename, FILE *file) {
if (n_soa == 3)
n_soa = 1;
if (n_soa == 0) {
isc_log_write(JOURNAL_COMMON_LOGARGS, ISC_LOG_ERROR,
"%s: journal file corrupt: missing "
"initial SOA", j->filename);
isc_log_write(JOURNAL_COMMON_LOGARGS, ISC_LOG_ERROR,
"%s: journal file corrupt: missing "
"initial SOA", j->filename);
FAIL(ISC_R_UNEXPECTED);
}
CHECK(dns_difftuple_create(diff.mctx, n_soa == 1 ?