changeset 2210:7677e1083d07

Increase _DW_ENV_STRING_SIZE to 257 bytes, this is the maximum size the utsname fields can be according to the Linux utsname man page. This seems to be a bit excessive but, this will prevent any possible issue on future operating system support. It also eliminates a bogus warning when compiling using gcc 9 and higher, which I believe is this gcc bug: warning: ‘__builtin_strncpy’ output may be truncated copying 64 bytes from a string of length 64 [-Wstringop-truncation] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88780
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 07 Dec 2020 20:01:03 +0000
parents 0b6e1b5c8b5e
children 9395c1efa98b
files dw.h gtk/dw.c gtk3/dw.c
diffstat 3 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/dw.h	Sat Dec 05 00:34:25 2020 +0000
+++ b/dw.h	Mon Dec 07 20:01:03 2020 +0000
@@ -1403,7 +1403,7 @@
 #define _DW_APP_ID_SIZE 100
 
 /* Use at least the linux utsname limit to avoid gcc fortify warnings */
-#define _DW_ENV_STRING_SIZE 65
+#define _DW_ENV_STRING_SIZE 257
 
 typedef struct _dwenv {
    /* Operating System Name and DW Build Date/Time */
--- a/gtk/dw.c	Sat Dec 05 00:34:25 2020 +0000
+++ b/gtk/dw.c	Mon Dec 07 20:01:03 2020 +0000
@@ -12517,12 +12517,12 @@
 void dw_environment_query(DWEnv *env)
 {
    struct utsname name;
-   char tempbuf[100] = { 0 }, *dot;
+   char tempbuf[_DW_ENV_STRING_SIZE] = { 0 }, *dot;
 
    uname(&name);
    memset(env, '\0', sizeof(DWEnv));
    strncpy(env->osName, name.sysname, sizeof(env->osName)-1);
-   strncpy(tempbuf, name.release, 99);
+   strncpy(tempbuf, name.release, sizeof(tempbuf)-1);
 
    strncpy(env->buildDate, __DATE__, sizeof(env->buildDate)-1);
    strncpy(env->buildTime, __TIME__, sizeof(env->buildTime)-1);
--- a/gtk3/dw.c	Sat Dec 05 00:34:25 2020 +0000
+++ b/gtk3/dw.c	Mon Dec 07 20:01:03 2020 +0000
@@ -11182,12 +11182,12 @@
 void dw_environment_query(DWEnv *env)
 {
    struct utsname name;
-   char tempbuf[100] = { 0 }, *dot;
+   char tempbuf[_DW_ENV_STRING_SIZE] = { 0 }, *dot;
 
    uname(&name);
    memset(env, '\0', sizeof(DWEnv));
    strncpy(env->osName, name.sysname, sizeof(env->osName)-1);
-   strncpy(tempbuf, name.release, 99);
+   strncpy(tempbuf, name.release, sizeof(tempbuf)-1);
 
    strncpy(env->buildDate, __DATE__, sizeof(env->buildDate)-1);
    strncpy(env->buildTime, __TIME__, sizeof(env->buildTime)-1);