diff options
author | Thomas Markwalder <tmark@isc.org> | 2019-06-12 10:06:30 -0400 |
---|---|---|
committer | Thomas Markwalder <tmark@isc.org> | 2019-06-12 10:06:30 -0400 |
commit | 97c155273c0df0c8518f226e2b5e338e3ad63e87 (patch) | |
tree | b4510c673655b2befb98ab9f77cbf203cc636dd5 /common | |
parent | 9bb1ce338651eefdaff33558f30ed6acdc4057c6 (diff) | |
parent | 71277027e98bcd94692406746b0685a7032d9fba (diff) | |
download | isc-dhcp-97c155273c0df0c8518f226e2b5e338e3ad63e87.tar.gz |
[master] GCC 9 compilation errors fixed.
Merge branch '15-confpars-c-has-invalid-error-messages-when-memory-allocation-fails'
Diffstat (limited to 'common')
-rw-r--r-- | common/discover.c | 4 | ||||
-rw-r--r-- | common/parse.c | 24 |
2 files changed, 18 insertions, 10 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 3ac4ebf7..c0fa4050 100644 --- a/common/parse.c +++ b/common/parse.c @@ -3,7 +3,7 @@ Common parser code for dhcpd and dhclient. */ /* - * Copyright (c) 2004-2017 by Internet Systems Consortium, Inc. ("ISC") + * Copyright (c) 2004-2019 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 1995-2003 by Internet Software Consortium * * This Source Code Form is subject to the terms of the Mozilla Public @@ -5566,19 +5566,25 @@ int parse_warn (struct parse *cfile, const char *fmt, ...) { va_list list; char lexbuf [256]; - char mbuf [1024]; - char fbuf [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))); |