File pegasus-2.7.0-strncat.patch of Package tog-pegasus

In file included from OperatingSystem.cpp:52:
In function 'char* strncat(char*, const char*, size_t)',
    inlined from 'Pegasus::CIMDateTime time_t_to_CIMDateTime(time_t*)' at OperatingSystem_Linux.cpp:347:
    /usr/include/bits/string3.h:153: warning: call to char* __builtin___strncat_chk(char*, const char*, unsigned int, unsigned int) might overflow destination buffer

---
 src/Providers/ManagedSystem/OperatingSystem/OperatingSystem_Linux.cpp |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

--- src/Providers/ManagedSystem/OperatingSystem/OperatingSystem_Linux.cpp.orig
+++ src/Providers/ManagedSystem/OperatingSystem/OperatingSystem_Linux.cpp
@@ -330,13 +330,14 @@ static CIMDateTime time_t_to_CIMDateTime
 
    CIMDateTime dt;
    char date_ascii_rep[CIM_DATE_TIME_ASCII_LEN];
+   size_t pos;
    char utc_offset[20];
    struct tm broken_time;
 
    dt = NULLTIME;
    localtime_r(time_to_represent, &broken_time);
-   if (strftime(date_ascii_rep, CIM_DATE_TIME_ASCII_LEN,
-                "%Y%m%d%H%M%S.000000", &broken_time))
+   if ((pos = strftime(date_ascii_rep, CIM_DATE_TIME_ASCII_LEN,
+                "%Y%m%d%H%M%S.000000", &broken_time)))
    {
 #if defined (PEGASUS_PLATFORM_LINUX_GENERIC_GNU)
       //-- the following makes use of a GNU extension
@@ -344,7 +345,8 @@ static CIMDateTime time_t_to_CIMDateTime
 #else
       snprintf(utc_offset, 20, "%+04ld", 0);
 #endif
-      strncat(date_ascii_rep, utc_offset, CIM_DATE_TIME_ASCII_LEN);
+      strncpy(date_ascii_rep + pos, utc_offset, CIM_DATE_TIME_ASCII_LEN - pos);
+      date_ascii_rep[CIM_DATE_TIME_ASCII_LEN-1] = '\0';
       dt = String(date_ascii_rep);
    }
 
openSUSE Build Service is sponsored by