qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] 09b94a: slirp: Correct size check in m_inc()


From: GitHub
Subject: [Qemu-commits] [qemu/qemu] 09b94a: slirp: Correct size check in m_inc()
Date: Tue, 07 Aug 2018 06:45:17 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 09b94ac0f29db3b022a77a5aa50dc9e37032689d
      
https://github.com/qemu/qemu/commit/09b94ac0f29db3b022a77a5aa50dc9e37032689d
  Author: Peter Maydell <address@hidden>
  Date:   2018-08-07 (Tue, 07 Aug 2018)

  Changed paths:
    M slirp/mbuf.c

  Log Message:
  -----------
  slirp: Correct size check in m_inc()

The data in an mbuf buffer is not necessarily at the start of the
allocated buffer. (For instance m_adj() allows data to be trimmed
from the start by just advancing the pointer and reducing the length.)
This means that the allocated buffer size (m->m_size) and the
amount of space from the m_data pointer to the end of the
buffer (M_ROOM(m)) are not necessarily the same.

Commit 864036e251f54c9 tried to change the m_inc() function from
taking the new allocated-buffer-size to taking the new room-size,
but forgot to change the initial "do we already have enough space"
check. This meant that if we were trying to extend a buffer which
had a leading gap between the buffer start and the data, we might
incorrectly decide it didn't need to be extended, and then
overrun the end of the buffer, causing memory corruption and
an eventual crash.

Change the "already big enough?" condition from checking the
argument against m->m_size to checking against M_ROOM().
This only makes a difference for the callsite in m_cat();
the other three callsites all start with a freshly allocated
mbuf from m_get(), which will have m->m_size == M_ROOM(m).

Fixes: 864036e251f54c9
Fixes: https://bugs.launchpad.net/qemu/+bug/1785670
Signed-off-by: Peter Maydell <address@hidden>
Reviewed-by: Samuel Thibault <address@hidden>
Message-id: address@hidden
Tested-by: Dr. David Alan Gilbert <address@hidden>



      **NOTE:** This service has been marked for deprecation: 
https://developer.github.com/changes/2018-04-25-github-services-deprecation/

      Functionality will be removed from GitHub.com on January 31st, 2019.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]