AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2010.07.08 16:25 "[Tiff] strlcpy vs strncpy", by Bob Friesenhahn
2010.07.08 18:03 "Re: [Tiff] strlcpy vs strncpy", by Lee Howard
2010.07.08 18:06 "Re: [Tiff] strlcpy vs strncpy", by Olivier Paquet
2010.07.11 17:36 "Re: [Tiff] strlcpy vs strncpy", by Edward Lam
2010.07.12 19:30 "[Tiff] strncpy in tiffcrop", by Richard Nolde
2010.07.12 20:31 "Re: [Tiff] strncpy in tiffcrop", by Edward Lam
2010.08.06 18:21 "Re: [Tiff] tiff4 on 32-bit Windows", by Toby Thain
2010.08.06 15:05 "[Tiff] tiff4 on 32-bit Windows", by John
2010.08.06 15:21 "Re: [Tiff] tiff4 on 32-bit Windows", by Bob Friesenhahn
2010.08.06 15:57 "Re: [Tiff] tiff4 on 32-bit Windows", by John
2010.08.06 16:24 "Re: [Tiff] tiff4 on 32-bit Windows", by Edward Lam
2010.08.06 16:51 "Re: [Tiff] tiff4 on 32-bit Windows", by Bob Friesenhahn
2010.08.06 16:38 "Re: [Tiff] tiff4 on 32-bit Windows", by Bob Friesenhahn
2010.08.09 12:59 "Re: [Tiff] tiff4 on 32-bit Windows", by John
2010.08.06 15:37 "Re: [Tiff] tiff4 on 32-bit Windows", by Olivier Paquet
2010.08.07 06:34 "[Tiff] tiffcp crashes on planar to strip conversion for < 8 bit", by Andreas Kleinert
2010.08.07 06:36 "Re: [Tiff] tiffcp crashes on tile to strip conversion for < 8 bit", by Andreas Kleinert
2010.08.15 04:45 "Re: [Tiff] tiffcp crashes on planar to strip conversion for < 8 bit", by Lee Howard
2010.07.10 11:04 "Re: [Tiff] strlcpy vs strncpy", by Albert Cahalan
2010.07.10 13:27 "Re: [Tiff] strlcpy vs strncpy", by Kevin Myers
2010.07.10 13:50 "Re: [Tiff] strlcpy vs strncpy", by Bob Friesenhahn
2010.07.11 07:34 "Re: [Tiff] strlcpy vs strncpy", by Albert Cahalan
2010.07.11 08:06 "Re: [Tiff] strlcpy vs strncpy", by Toby Thain
2010.07.11 14:35 "Re: [Tiff] strlcpy vs strncpy", by Bob Friesenhahn
2010.07.10 13:39 "Re: [Tiff] strlcpy vs strncpy", by Bob Friesenhahn
2010.07.11 08:18 "Re: [Tiff] strlcpy vs strncpy", by Albert Cahalan
2010.07.11 16:35 "Re: [Tiff] strlcpy vs strncpy", by Bob Friesenhahn
2010.07.12 17:34 "Re: [Tiff] strlcpy vs strncpy", by Dmitry V. Levin
2010.07.12 18:13 "Re: [Tiff] strlcpy vs strncpy", by Bob Friesenhahn
2010.08.02 19:47 "Re: [Tiff] BigTIFF Support in LibTiff", by Gajera Tejas
2010.08.02 19:25 "[Tiff] BigTIFF Support in LibTiff", by Gajera Tejas
2010.08.02 19:34 "Re: [Tiff] BigTIFF Support in LibTiff", by Bob Friesenhahn
2010.08.19 17:18 "[Tiff] tiff2ps page sizing options", by Richard Nolde
2010.08.23 04:54 "Re: [Tiff] tiff2ps page sizing options", by Lee Howard

2010.07.11 07:34 "Re: [Tiff] strlcpy vs strncpy", by Albert Cahalan

On Sat, Jul 10, 2010 at 9:27 AM, Kevin Myers <KevinMyers@austin.rr.com> wrote:

Actually the fact that strncpy zero fills the remainder of the array strongly suggests that it *was* intended to be used exactly as many people are (mis)using it. filling the array automatically adds a null  Zero

> terminator, except in the case when string length = buffer length.  If you

did't want to automatically add a null terminator, then why zero fill the array???

In times past, it was common to have text stored in a fixed-size place, padded out with NUL bytes, and no expectation that there would be a NUL at the end. I know this seems strange today. Perhaps it is for compatibility with some long-forgotten non-C language. Requiring a NUL byte would increase the size of a record, so maybe people were just trying to save space in a world where fixed-size records were the norm yet every byte was precious.

With regard to strlcpy truncating the string, how can that possibly cause a security problem???

There are plenty of ways. Perhaps code later checks the new length, then ends up filling it with the old (longer) data. Perhaps the allocation is zero bytes, strlcpy thus fails to write the NUL byte, and ultimately you leak private data. Perhaps the allocation is zero bytes, strlcpy is buggy (wrongly writing the NUL byte), and a function pointer is trashed. There is more to security than buffer overflows of course; perhaps you turn filename.exe.tif into filename.exe when you truncate. Perhaps the truncation removes a closing quote or comment mark, leading to some critical script or config data being swallowed up.

I don't see that at all. like strlcpy is doing  Seems *exactly* what strcpy should have been doing for all these years to prevent

I'm not sure strcpy ever had a legitimate purpose. Use memcpy.

Either you know the length (you can use memcpy) or you don't know the length (you have a bug, truncation or otherwise).

I tend to agree regarding the use of standard implementations rather than rolling your own whenever possible. Bob F. is well versed in  However, portability issues because of his support for GraphicsMagick on multiple platforms. he thinks there are enough compilers in widespread use that  If don't support strlcpy to justify rolling his own, then he may be right.

I think Linux and Windows are in widespread use. :-) You can find strlcpy on *BSD and I think on recent Solaris. It has been rejected by the glibc maintainer.