Does anybody have a version of SPRINTF with bounds checking and flame

PAD Powell padpowell at wateng.UUCP
Mon Aug 20 00:46:57 AEST 1984


Once again I have been stung with by sprintf().  Why was sprintf() not
provided with a "bounds" check version, like
sprintf( target, count, format, args )
	char *target, *format;
	int count;
	void args;

I am seriously considering adding this functionailt, and calling it
snprintf(), A LA strcmp(), strncmp().

Problems caused by overflowing the allocated string took two days
to track down, as sprintf was corrupting some MALLOC headers...

If anybody has comments or suggestions, I would be more than happy to hear them.
Patrick ("And don't even mention Garbage Collection") Powell



More information about the Comp.unix.wizards mailing list