Buffer overflow in name_to_tcb

Lasse Kliemann <[email protected]> Mon, 13 Jun 2011 18:55:06 +0200
Newsgroups gmane.comp.archivers.star.user
Message-ID <[email protected]>
--===============1071587589095127938==
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="UugvWAfsgieZRqgk"
Content-Disposition: inline


--UugvWAfsgieZRqgk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Compiled star with CFLAGS=3D"-D_FORTIFY_SOURCE=3D2 -O2" on GCC 4.5.3,=20
Glibc 2.13, Linux 2.6.39.1. Then created a file with a long name=20
(100 characters) and tried to pack it up:

$ mkdir test
$ cd test
$ touch 0123456789012345678901234567890123456789012345678901234567890123456=
789012345678901234567890123456789
$ star -c f=3D../test.tar .
*** buffer overflow detected ***: /tmp/schily-2011-06-05/star/OBJ/i686-linu=
x-cc/star terminated
=3D=3D=3D=3D=3D=3D=3D Backtrace: =3D=3D=3D=3D=3D=3D=3D=3D=3D
/usr/lib/libc.so.6(__fortify_fail+0x40)[0xb77a17d0]
/usr/lib/libc.so.6(+0xe37ea)[0xb779f7ea]
/usr/lib/libc.so.6(__strcpy_chk+0x3f)[0xb779eb3f]
/tmp/schily-2011-06-05/star/OBJ/i686-linux-cc/star[0x8070c84]
/tmp/schily-2011-06-05/star/OBJ/i686-linux-cc/star[0x80610cf]
/tmp/schily-2011-06-05/star/OBJ/i686-linux-cc/star[0x8061f71]
/tmp/schily-2011-06-05/star/OBJ/i686-linux-cc/star[0x806217e]
/tmp/schily-2011-06-05/star/OBJ/i686-linux-cc/star[0x804c14b]
/tmp/schily-2011-06-05/star/OBJ/i686-linux-cc/star[0x8051b4b]
/usr/lib/libc.so.6(__libc_start_main+0xe6)[0xb76d2de6]
/tmp/schily-2011-06-05/star/OBJ/i686-linux-cc/star[0x804a591]
[ ... snip ... ]

I tracked this down to line 158 in longnames.c, i.e.,
  strcpy(ptb->dbuf.t_name, name);

A look in star.h tells that t_name is only NAMSIZ long, which is 100.

So something is not going well here.

The problem may have been there for a long time, but recent GCCs=20
appear to be more strict with FORTIFY_SOURCE. I recently switched=20
=66rom 4.3.x to 4.5.x.

--UugvWAfsgieZRqgk
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQIcBAEBAgAGBQJN9kDqAAoJEFYll6N4nhdvu9oQAKAzPbM9bTt2PsI1ID6CuZKK
KM647rgKsQzFvTm1WJBZaVlMNtKdrSTgh7icIr/DLg246lZuDYu3xzeJv/VenKU/
0aPQq7gZclQqIGU1zNmH4kTu81dfTGBu5vOgbtpHV3MLHbkUBGr//EgG14kpwe/Z
TfJOCmRNFgAJQ5neoewNIKGsTn0Bu2bND+4MwPYRlz26zWdfnBT/wEUb+Y9gOMbu
nKWTcaPnX9nZotx0xz1JPH4qrQBDbecnc++Js/smp8i2QMyt25vaChnRKwU44MGz
7cKbh1ZFp4xDPSI+wCz0efIlX1l08IuuQrlerzO8YUxlDq4ulpe+EY60uJ254Vtc
nFM7H2FOkdu0l2Q8OzKidMkQn80/fjTg6Jg1BpiCKjfO745ppHIg+LaknSFCJjhy
8ekE9fyOQXDkR2oD6R648bb23eTNAlW7HV6MHz9Ajtf8WGik91P98OYIVvAsdSmO
W3/GVJ2rRpGMy6w2GMF4X53iuQn/GlW+jPT+WiwKSVA+EQ32vqJKKTvYPDQ+EVzr
/UJqkt9AMiowfIVwLa9CWd6fioKrAERyTVMXzsLfQcs6KWjOad4R6J5DSzSxBnsl
X6IOF/6UDUyVs5TsTtdwttDslQWsY3mxUB8GcBhKHHAmI+1NmaGl+pONoR/JbvSM
lPlrUQzJpxbmKLKBqEQ7
=HtIy
-----END PGP SIGNATURE-----

--UugvWAfsgieZRqgk--

--===============1071587589095127938==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Star-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/star-users

--===============1071587589095127938==--