diff options
author | Thomas Markwalder <tmark@isc.org> | 2019-06-11 13:38:59 -0400 |
---|---|---|
committer | Thomas Markwalder <tmark@isc.org> | 2019-06-12 09:57:33 -0400 |
commit | e119ecf6b782253bfc3528e4779481661e2b9bb8 (patch) | |
tree | d4e0780ed8cce4b496514c788628a23e344beaef /common | |
parent | 753d458b1f257cc2107454db158e14e92fcecb11 (diff) | |
download | isc-dhcp-e119ecf6b782253bfc3528e4779481661e2b9bb8.tar.gz |
[#15,!10] Addressed review comments
common/discover.c
discover_interfaces() - replaced strncpy with memcpy
common/parse.c
parse_warn() - added final message buffer rather than reuse mbuf,
pass size into do_percentm call
includes/dhcpd.h
struct interface_info - restored size of name
includes/omapip/omapip_p.*
do_percentm() - added output buffer size parameter
omapip/errwarn.c
pass size of output buffer into calls to do_percentm
Diffstat (limited to 'common')
-rw-r--r-- | common/discover.c | 4 | ||||
-rw-r--r-- | common/parse.c | 20 |
2 files changed, 16 insertions, 8 deletions
diff --git a/common/discover.c b/common/discover.c index 6ef88529..226dbc4a 100644 --- a/common/discover.c +++ b/common/discover.c @@ -643,7 +643,9 @@ discover_interfaces(int state) { log_fatal("Error allocating interface %s: %s", info.name, isc_result_totext(status)); } - strncpy(tmp->name, info.name, sizeof(tmp->name) - 1); + + memcpy(tmp->name, info.name, sizeof(tmp->name)); + interface_snorf(tmp, ir); interface_dereference(&tmp, MDL); tmp = interfaces; /* XXX */ diff --git a/common/parse.c b/common/parse.c index 35b0b8de..c0fa4050 100644 --- a/common/parse.c +++ b/common/parse.c @@ -5566,19 +5566,25 @@ int parse_warn (struct parse *cfile, const char *fmt, ...) { va_list list; char lexbuf [256]; - char mbuf [1024]; + char mbuf [1024]; /* errorwarn.c CVT_BUF_MAX + 1 */ char fbuf [2048]; + char final[4096]; unsigned i, lix; - - do_percentm (mbuf, fmt); + + /* Replace %m in fmt with errno error text */ + do_percentm (mbuf, sizeof(mbuf), fmt); + /* %Audit% This is log output. %2004.06.17,Safe% * If we truncate we hope the user can get a hint from the log. */ + + /* Prepend the file and line number */ snprintf (fbuf, sizeof fbuf, "%s line %d: %s", cfile -> tlname, cfile -> lexline, mbuf); - + + /* Now add the var args to the format for the final log message. */ va_start (list, fmt); - vsnprintf (mbuf, sizeof mbuf, fbuf, list); + vsnprintf (final, sizeof final, fbuf, list); va_end (list); lix = 0; @@ -5594,14 +5600,14 @@ int parse_warn (struct parse *cfile, const char *fmt, ...) lexbuf [lix] = 0; #ifndef DEBUG - syslog (LOG_ERR, "%s", mbuf); + syslog (LOG_ERR, "%s", final); syslog (LOG_ERR, "%s", cfile -> token_line); if (cfile -> lexchar < 81) syslog (LOG_ERR, "%s^", lexbuf); #endif if (log_perror) { - IGNORE_RET (write (STDERR_FILENO, mbuf, strlen (mbuf))); + IGNORE_RET (write (STDERR_FILENO, final, strlen (final))); IGNORE_RET (write (STDERR_FILENO, "\n", 1)); IGNORE_RET (write (STDERR_FILENO, cfile -> token_line, strlen (cfile -> token_line))); |