tar segfaults (busybox 1.8.1)

Ralf Friedl Ralf.Friedl at online.de
Fri Nov 16 22:10:19 UTC 2007


Denys Vlasenko wrote:
> On Friday 16 November 2007 12:53, Ralf Friedl wrote:
>   
>> glibc can't to this, it must be the compiler, maybe with some special
>> options.
>>     
> With magic macro definition of strcpy, it can.
>   
You are right.
I found this in /usr/include/bits/string3.h:
#define strcpy(dest, src) \
  ((__bos (dest) != (size_t) -1)                                        \
   ? __builtin___strcpy_chk (dest, src, __bos (dest))                   \
   : __strcpy_ichk (dest, src))
static __inline__ char *
__attribute__ ((__always_inline__))
__strcpy_ichk (char *__restrict __dest, const char *__restrict __src)
{
  return __builtin___strcpy_chk (__dest, __src, __bos (__dest));
}

So it seems to be some macro magic together with some compiler builtins. 
__bos seems to be __builtin_object_size
I also found this in /usr/include/string.h:
# if __USE_FORTIFY_LEVEL > 0 && !defined __cplusplus
/* Functions with security checks.  */
#  include <bits/string3.h>
# endif
#endif


So it seems that __USE_FORTIFY_LEVEL or _FORTIFY_SOURCE was defined when 
busybox was compiled.

Regards
Ralf Friedl



More information about the busybox mailing list