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

Possible use of freed memory when removing old data from valuecache

XMLWordPrintable

    • Sprint 28, Sprint 29
    • 0.5

      The following code uses chunk's first_value and last_value properties after the chunk is freed. In current memory allocator implementation it works normally, as the freed memory block is not changed by current process and valuecache shared memory is locked during this operation and cannot be changed by other processes.

      However the approach is obviously wrong and there might be problems if the memory allocator is changed in future, so it's better to fix it.

      static size_t	vch_item_free_chunk(zbx_vc_item_t *item, zbx_vc_chunk_t *chunk)
      {
      	size_t	freed;
      
      	freed = vc_item_free_values(item, chunk->slots, chunk->first_value, chunk->last_value);
      
      	__vc_mem_free_func(chunk);
      
      	return freed + sizeof(zbx_vc_chunk_t) + (chunk->last_value - chunk->first_value) * sizeof(zbx_history_record_t);
      }
      

            MVekslers Michael Veksler
            wiper Andris Zeila
            Team C
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: