]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Resize unamebuf[] to avoid warnings about snprintf() not having
authorMark Andrews <marka@isc.org>
Tue, 23 Jun 2020 07:00:43 +0000 (17:00 +1000)
committerMark Andrews <marka@isc.org>
Wed, 24 Jun 2020 23:26:22 +0000 (09:26 +1000)
enough buffer space.  Also change named_os_uname() prototype so
that it is now returning (const char *) rather than (char *).  If
uname() is not supported on a UNIX build prepopulate unamebuf[]
with "unknown architecture".

(cherry picked from commit 4bc3de070fc9c0bc4d8d15d207e0b1352cd20434)

bin/named/unix/include/named/os.h
bin/named/unix/os.c
bin/named/win32/include/named/os.h
bin/named/win32/os.c

index 5e5d2b894fdad2a278b665ab8408279bef1a1fea..dd437cc45eafc7a5231ce311afb5e65698734249 100644 (file)
@@ -73,7 +73,7 @@ named_os_tzset(void);
 void
 named_os_started(void);
 
-char *
+const char *
 named_os_uname(void);
 
 #endif /* NAMED_OS_H */
index 6c413b0f45def6de53e20ed91ce91f6e7fa93525..25650608e04de8ccd792eebefa67f8e9ec2460a2 100644 (file)
@@ -903,8 +903,12 @@ named_os_tzset(void) {
 #endif /* ifdef HAVE_TZSET */
 }
 
-static char unamebuf[BUFSIZ];
-static char *unamep = NULL;
+#ifdef HAVE_UNAME
+static char unamebuf[sizeof(struct utsname)];
+#else
+static const char unamebuf[] = { "unknown architecture" };
+#endif
+static const char *unamep = NULL;
 
 static void
 getuname(void) {
@@ -919,13 +923,11 @@ getuname(void) {
 
        snprintf(unamebuf, sizeof(unamebuf), "%s %s %s %s", uts.sysname,
                 uts.machine, uts.release, uts.version);
-#else  /* ifdef HAVE_UNAME */
-       snprintf(unamebuf, sizeof(unamebuf), "unknown architecture");
 #endif /* ifdef HAVE_UNAME */
        unamep = unamebuf;
 }
 
-char *
+const char *
 named_os_uname(void) {
        if (unamep == NULL) {
                getuname();
index c177bf4adcc46d7d367e7371e0423e8ea1dcea04..4af96316cc7488c99db684a9c719a3070ab4d419 100644 (file)
@@ -70,7 +70,7 @@ named_os_tzset(void);
 void
 named_os_started(void);
 
-char *
+const char *
 named_os_uname(void);
 
 #endif /* NAMED_OS_H */
index a7edacaf535b0be6e84135bf1921ad055ca967f4..3df95e773d08567c2a56aea6fb5e9efe294974d4 100644 (file)
@@ -393,7 +393,7 @@ named_os_started(void) {
 }
 
 static char unamebuf[BUFSIZ];
-static char *unamep = NULL;
+static const char *unamep = NULL;
 
 static void
 getuname(void) {
@@ -462,7 +462,7 @@ err:
  * GetVersionEx() returns 6.2 (aka Windows 8.1) since it was obsoleted
  * so we had to switch to the recommended way to get the Windows version.
  */
-char *
+const char *
 named_os_uname(void) {
        if (unamep == NULL) {
                getuname();