Hi, hackers

Some conditions in shm_toc_insert and shm_toc_allocate are bogus, like:

        if (toc_bytes + nbytes > total_bytes || toc_bytes + nbytes < toc_bytes)

Remove the condition `toc_bytes + nbytes < toc_bytes` and take a 
sizeof(shm_entry) into account in shm_toc_allocate though
shm_toc_allocate does that too.

        /* Check for memory exhaustion and overflow. */
        - if (toc_bytes + nbytes > total_bytes || toc_bytes + nbytes < 
toc_bytes)
        + if (toc_bytes + sizeof(shm_toc_entry) + nbytes > total_bytes)
         {
        SpinLockRelease(&toc->toc_mutex);

shm_toc_freespace is introduced with shm_toc by original commit 6ddd5137b2, but 
is not used since then, so remove it.


Regards,
Zhang Mingli

Attachment: v0-0001-Fix-condition-in-shm_toc-and-remove-unused-functi.patch
Description: Binary data

Reply via email to