]> git.ipfire.org Git - thirdparty/dhcp.git/blobdiff - omapip/errwarn.c
[#182] Corrected CVE: CVE-2021-25217
[thirdparty/dhcp.git] / omapip / errwarn.c
index 8cd0098c9097ebce960428fcfaf1bf960baf0cc3..38dd9c5384db8dd7b5a400594ca21a99302da84b 100644 (file)
@@ -4,12 +4,12 @@
 
 /*
  * Copyright (c) 1995 RadioMail Corporation.
- * Copyright (c) 2004-2017 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2022 Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 1996-2003 by Internet Software Consortium
  *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  *
  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
@@ -20,8 +20,8 @@
  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  *   Internet Systems Consortium, Inc.
- *   950 Charter Street
- *   Redwood City, CA 94063
+ *   PO Box 360
+ *   Newmarket, NH 03857 USA
  *   <info@isc.org>
  *   https://www.isc.org/
  *
@@ -54,7 +54,7 @@ void log_fatal (const char * fmt, ... )
 {
   va_list list;
 
-  do_percentm (fbuf, fmt);
+  do_percentm (fbuf, sizeof fbuf, fmt);
 
   /* %Audit% This is log output. %2004.06.17,Safe%
    * If we truncate we hope the user can get a hint from the log.
@@ -93,7 +93,7 @@ int log_error (const char * fmt, ...)
 {
   va_list list;
 
-  do_percentm (fbuf, fmt);
+  do_percentm (fbuf, sizeof fbuf, fmt);
 
   /* %Audit% This is log output. %2004.06.17,Safe%
    * If we truncate we hope the user can get a hint from the log.
@@ -120,7 +120,7 @@ int log_info (const char *fmt, ...)
 {
   va_list list;
 
-  do_percentm (fbuf, fmt);
+  do_percentm (fbuf, sizeof fbuf, fmt);
 
   /* %Audit% This is log output. %2004.06.17,Safe%
    * If we truncate we hope the user can get a hint from the log.
@@ -147,7 +147,7 @@ int log_debug (const char *fmt, ...)
 {
   va_list list;
 
-  do_percentm (fbuf, fmt);
+  do_percentm (fbuf, sizeof fbuf, fmt);
 
   /* %Audit% This is log output. %2004.06.17,Safe%
    * If we truncate we hope the user can get a hint from the log.
@@ -170,8 +170,9 @@ int log_debug (const char *fmt, ...)
 
 /* Find %m in the input string and substitute an error message string. */
 
-void do_percentm (obuf, ibuf)
+void do_percentm (obuf, obufsize, ibuf)
      char *obuf;
+     size_t obufsize;
      const char *ibuf;
 {
        const char *s = ibuf;
@@ -191,13 +192,13 @@ void do_percentm (obuf, ibuf)
                                if (!m)
                                        m = "<unknown error>";
                                len += strlen (m);
-                               if (len > CVT_BUF_MAX)
+                               if (len > obufsize - 1)
                                        goto out;
                                strcpy (p - 1, m);
                                p += strlen (p);
                                ++s;
                        } else {
-                               if (++len > CVT_BUF_MAX)
+                               if (++len > obufsize - 1)
                                        goto out;
                                *p++ = *s++;
                        }
@@ -205,7 +206,7 @@ void do_percentm (obuf, ibuf)
                } else {
                        if (*s == '%')
                                infmt = 1;
-                       if (++len > CVT_BUF_MAX)
+                       if (++len > obufsize - 1)
                                goto out;
                        *p++ = *s++;
                }