mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 06:55:30 +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:
5
CHANGES
5
CHANGES
@@ -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]
|
2451. [port] solaris: handle runtime linking better. [RT #18356]
|
||||||
|
|
||||||
2450. [doc] Fix lwresd docbook problem for manual page.
|
2450. [doc] Fix lwresd docbook problem for manual page.
|
||||||
|
@@ -15,23 +15,57 @@
|
|||||||
* PERFORMANCE OF THIS SOFTWARE.
|
* 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 */
|
/*! \file */
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <isc/log.h>
|
||||||
#include <isc/mem.h>
|
#include <isc/mem.h>
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
|
|
||||||
#include <dns/journal.h>
|
#include <dns/journal.h>
|
||||||
|
#include <dns/log.h>
|
||||||
|
#include <dns/result.h>
|
||||||
#include <dns/types.h>
|
#include <dns/types.h>
|
||||||
|
|
||||||
#include <stdlib.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
|
int
|
||||||
main(int argc, char **argv) {
|
main(int argc, char **argv) {
|
||||||
char *file;
|
char *file;
|
||||||
isc_mem_t *mctx = NULL;
|
isc_mem_t *mctx = NULL;
|
||||||
|
isc_result_t result;
|
||||||
|
isc_log_t *lctx = NULL;
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
printf("usage: %s journal\n", argv[0]);
|
printf("usage: %s journal\n", argv[0]);
|
||||||
@@ -41,8 +75,12 @@ main(int argc, char **argv) {
|
|||||||
file = argv[1];
|
file = argv[1];
|
||||||
|
|
||||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
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);
|
isc_mem_detach(&mctx);
|
||||||
return(0);
|
return(result != ISC_R_SUCCESS ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* PERFORMANCE OF THIS SOFTWARE.
|
* 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>
|
#include <config.h>
|
||||||
|
|
||||||
@@ -1402,7 +1402,7 @@ dns_journal_print(isc_mem_t *mctx, const char *filename, FILE *file) {
|
|||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
isc_log_write(JOURNAL_COMMON_LOGARGS, ISC_LOG_ERROR,
|
isc_log_write(JOURNAL_COMMON_LOGARGS, ISC_LOG_ERROR,
|
||||||
"journal open failure: %s: %s",
|
"journal open failure: %s: %s",
|
||||||
isc_result_totext(result), j->filename);
|
isc_result_totext(result), filename);
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1440,9 +1440,9 @@ dns_journal_print(isc_mem_t *mctx, const char *filename, FILE *file) {
|
|||||||
if (n_soa == 3)
|
if (n_soa == 3)
|
||||||
n_soa = 1;
|
n_soa = 1;
|
||||||
if (n_soa == 0) {
|
if (n_soa == 0) {
|
||||||
isc_log_write(JOURNAL_COMMON_LOGARGS, ISC_LOG_ERROR,
|
isc_log_write(JOURNAL_COMMON_LOGARGS, ISC_LOG_ERROR,
|
||||||
"%s: journal file corrupt: missing "
|
"%s: journal file corrupt: missing "
|
||||||
"initial SOA", j->filename);
|
"initial SOA", j->filename);
|
||||||
FAIL(ISC_R_UNEXPECTED);
|
FAIL(ISC_R_UNEXPECTED);
|
||||||
}
|
}
|
||||||
CHECK(dns_difftuple_create(diff.mctx, n_soa == 1 ?
|
CHECK(dns_difftuple_create(diff.mctx, n_soa == 1 ?
|
||||||
|
Reference in New Issue
Block a user