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

    Details

    • Team:
      Team A
    • Sprint:
      Sprint 71 (Dec 2020)
    • Story Points:
      0.125

      Description

      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));
      

        Attachments

          Activity

            People

            Assignee:
            vso Vladislavs Sokurenko
            Reporter:
            vso Vladislavs Sokurenko
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: