aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* libsandbox: tweak edge cases of realloc a bitMike Frysinger2015-12-191-1/+5
| | | | | | | | | | | | We need to return NULL when passed a size of 0 as the API requires the return value be usable w/free, but we just freed the pointer so the ret will cause memory corruption later on. When we go to preserve the old content, we don't need the MIN check as we already verified that a few lines up. But leave it for defensive purposes as gcc already optimizes it out for us. Just comment things. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: fix old_malloc_size check on reallocDenis Lisov2015-12-191-2/+3
| | | | | | | | | | Realloc uses SB_MALLOC_TO_SIZE assuming it returns the usable size, while it is really the mmap size, which is greater. Thus it may fail to reallocate even if required. URL: https://bugs.gentoo.org/568714 Signed-off-by: Denis Lisov <dennis.lissov@gmail.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: fix memory alignmentv2.10Mike Frysinger2015-12-191-3/+6
| | | | | | | | | | | Some targets (like sparc32) have higher alignment requirements for 64-bit values than size_t (which is 4 bytes on sparc32). If we happen to return 4 byte aligned memory which is used to hold a 64-bit, we get bus errors. Use the same algorithm that dlmalloc does. URL: https://bugs.gentoo.org/565630 Reported-by: Denis Kaganovich <mahatma@eu.by> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* significantly overhaul output helpersMike Frysinger2012-06-231-4/+2
| | | | | | | | | | | | | | | | | | | | There are a few major points we want to hit here: - have all output from libsandbox go through portage helpers when we are in the portage environment so that output is properly logged - convert SB_E{info,warn,error} to sb_e{info,warn,error} to match style of other functions and cut down on confusion - move all abort/output helpers to libsbutil so it can be used in all source trees and not just by libsandbox - migrate all abort points to the centralized sb_ebort helper Unfortunately, it's not terribly easy to untangle these into separate patches, but hopefully this shouldn't be too messy as much of it is mechanical: move funcs between files, and change the name of funcs that get called. URL: http://bugs.gentoo.org/278761 Reported-by: Mounir Lamouri <volkmar@gentoo.org> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: use mmap directly for internal memoryMike Frysinger2009-10-261-0/+20
| | | | | | | | | | | | | | | Some packages that do library tricks like sandbox override the mmap() symbols. If their implementation ends up calling functions that sandbox has overridden, then we can easily hit an infinite loop. sb-fopen -> sb-malloc -> external mmap -> sb-open -> whoops! So for the internal memory functions, make sure we call directly to the C library's mmap() functions. This way our internal memory implementation should be free from external forces. URL: http://bugs.gentoo.org/290249 Reported-by: Diego E. Pettenò <flameeyes@gentoo.org> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: initial support for tracing of static binaries via ptrace()Mike Frysinger2009-03-181-0/+3
| | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: improve debugging supportMike Frysinger2009-03-111-6/+1
| | | | | | | Dump symbols before we abort and if SANDBOX_GDB is enabled in the env, automatically launch & attach gdb to the crashing setup. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: do not call x*() memory funcs in memory replacement codev1.3.7Mike Frysinger2009-02-131-5/+17
| | | | | | | | | | | As Maximilian points out, the internal memory funcs in libsandbox are already called by the x*() type funcs which means error checking occurs at the higher level. So we don't want to do it at the inner level either as that will lose the real file/location where the memory allocation occured. URL: http://bugs.gentoo.org/257179 Signed-off-by: Maximilian Grothusmann <maxi-gentoo@own-hero.de> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: fix call to backtrace()Mike Frysinger2009-02-071-1/+1
| | | | | | | The size argument to backtrace() is the number of elements, not the number of bytes. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsbutil: cleanup x* memory functionsMike Frysinger2008-12-311-14/+4
| | | | | | | | Pull the x* memory functions out of rcscripts and into libsbutil and change their style to match the rest of sbutil. Also add xzalloc() and xstrdup(), and convert pointless strndup() usage to strdup(). Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* unify SB_E{INFO,WARN,ERROR} functions and have them call the internal ↵Mike Frysinger2008-11-161-2/+1
| | | | | | sb_printf function Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: do a little memory memory checking on free() to make sure the ↵Mike Frysinger2008-11-101-4/+13
| | | | | | pointer didnt get corrupt Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: create local memory functionsMike Frysinger2008-11-091-0/+82
Some packages create their own set of memory functions and if libsandbox tries to use those, we tend to crash. So have all libsandbox code use its internal memory functions based on mmap(). URL: http://bugs.gentoo.org/164656 Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Ed Catmur <ed@catmur.co.uk> Signed-off-by: Mike Frysinger <vapier@gentoo.org>