Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: safe strcpy()?

From: Ed Carp <erc(at)pobox.com>
Date: Tue Jan 28 2003 - 04:44:24 EST


On Tue, 28 Jan 2003, Michal Zalewski wrote:

> There are several interesting ways to prevent the problem without making

I wasn't able to find such a function - do you have an example?

Most of the buffers we use are fixed-size, to side-step problems with malloc() and free(), and so we've been able to partially get around this problem by writing strcpy() as a macro - for example:

char buf[512];

our_strcpy(buf, source);

if our_strcpy() is written as a macro, then sizeof(buf) will return 512, and so we can do bounds checking. The problem comes in when someone does something like:

ptr = buf;
our_strcpy(ptr, source);

Do you need help?X

How can one determine the size of the buffer being pointed to? sizeof(ptr) returns 4 :( Technically, that's correct, but that's not what I meant ;)

-- 
Ed Carp, N7EKG          
http://www.pobox.com/~erc               214/986-5870
Licensed Texas Peace Officer
Computer Crime Investigation Consultant

Director, Software Development
Escapade Server-Side Scripting Engine Development Team
http://www.squishedmosquito.com

Microsoft Front Page - the official HTML editor of Al Qaeda
Microsoft Hotmail - the official email of Al Qaeda
Received on Tue Jan 28 12:19:43 2003

This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 14:02:45 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library