]> 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:21:36 +0000 (23:21 +0000)
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".

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 3c5b19d383cfe8f2be7b1f6001e08121a6d3566b..6d37c699659d5fc4417c3fb144707516a6d4a956 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();