mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 22:45:39 +00:00
use vsnprintf, now portable because of isc/print.c.
removed static forward declaration of isc_log_vwrite(), now public. declared assignchannel() as static.
This commit is contained in:
@@ -15,18 +15,15 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: log.c,v 1.4 1999/10/11 13:28:49 tale Exp $ */
|
/* $Id: log.c,v 1.5 1999/10/11 14:50:51 tale Exp $ */
|
||||||
|
|
||||||
/* Principal Authors: DCL */
|
/* Principal Authors: DCL */
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdio.h> /* For remove(). */
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <isc/assertions.h>
|
#include <isc/assertions.h>
|
||||||
@@ -142,11 +139,7 @@ isc_logchannellist_t default_channel;
|
|||||||
/*
|
/*
|
||||||
* Forward declarations.
|
* Forward declarations.
|
||||||
*/
|
*/
|
||||||
static void
|
static isc_result_t
|
||||||
isc_log_vwrite(isc_log_t *lctx, isc_logcategory_t *category,
|
|
||||||
isc_logmodule_t *module, int level, const char *format,
|
|
||||||
va_list args);
|
|
||||||
isc_result_t
|
|
||||||
assignchannel(isc_log_t *lctx, unsigned int category_id,
|
assignchannel(isc_log_t *lctx, unsigned int category_id,
|
||||||
isc_logmodule_t *module, isc_logchannel_t *channel);
|
isc_logmodule_t *module, isc_logchannel_t *channel);
|
||||||
|
|
||||||
@@ -548,7 +541,7 @@ isc_log_closefilelogs(isc_log_t *lctx) {
|
|||||||
**** Internal functions
|
**** Internal functions
|
||||||
****/
|
****/
|
||||||
|
|
||||||
isc_result_t
|
static isc_result_t
|
||||||
assignchannel(isc_log_t *lctx, unsigned int category_id,
|
assignchannel(isc_log_t *lctx, unsigned int category_id,
|
||||||
isc_logmodule_t *module, isc_logchannel_t *channel)
|
isc_logmodule_t *module, isc_logchannel_t *channel)
|
||||||
{
|
{
|
||||||
@@ -851,25 +844,11 @@ isc_log_vwrite(isc_log_t *lctx, isc_logcategory_t *category,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Oh, that vsnprintf were ANSI C portable.
|
* Only format the message once.
|
||||||
*/
|
*/
|
||||||
if (lctx->buffer[0] == '\0' &&
|
if (lctx->buffer[0] == '\0')
|
||||||
vsprintf(lctx->buffer, format, args) > LOG_BUFFER_SIZE) {
|
(void)vsnprintf(lctx->buffer, sizeof(lctx->buffer),
|
||||||
/*
|
format, args);
|
||||||
* vsprintf() overran its buffer. This might have
|
|
||||||
* just been because the buffer was too small, or
|
|
||||||
* in the worst case it was a malicious attack on the
|
|
||||||
* program. In any event, who knows what got
|
|
||||||
* corrupted in memory. It is safest just to exit.
|
|
||||||
*
|
|
||||||
* If it _was_ an attack, the attackers have
|
|
||||||
* unfortunately succeeded in a denial of service.
|
|
||||||
* XxXDCL NT
|
|
||||||
*/
|
|
||||||
syslog(LOG_CRIT, "vsprintf overran its buffer; "
|
|
||||||
"possible hack attempt, exiting");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (channel->type) {
|
switch (channel->type) {
|
||||||
case ISC_LOG_TOFILE:
|
case ISC_LOG_TOFILE:
|
||||||
|
Reference in New Issue
Block a user