Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-18755

Out of memory occurs on platforms where size_t is 8 bytes

XMLWordPrintable

    • Sprint 71 (Dec 2020)
    • 0.125

      The following error occurs on Windows when attempting to use string_replace function though may happen on some other exotic platform:

      file:..\..\..\src\libs\zbxcommon\str.c,line:388 zbx_malloc: out of memory. Requested 4294967614 bytes.

      Diff is signed, while count is unsigned.

      long diff;
      unsigned long count = 0; 
      

      Diff can be negative:

      diff = (long)strlen(sub_str2) - len;        /* allocate new memory */
      

      Diff is add to strlen, however count is unsigned so count*diff may become large number in my case 4294967614 which is larger then maximum unsigned long type.

      	new_str = (char *)zbx_malloc(new_str, (size_t)(strlen(str) + count*diff + 1)*sizeof(char));
      

            vso Vladislavs Sokurenko
            vso Vladislavs Sokurenko
            Team A
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: