From owner-freebsd-bugs Fri Jun 9 01:17:06 1995 Return-Path: bugs-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id BAA22528 for bugs-outgoing; Fri, 9 Jun 1995 01:17:06 -0700 Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.34]) by freefall.cdrom.com (8.6.10/8.6.6) with ESMTP id BAA22509 for ; Fri, 9 Jun 1995 01:16:53 -0700 Received: (from bde@localhost) by godzilla.zeta.org.au (8.6.9/8.6.9) id SAA23942; Fri, 9 Jun 1995 18:12:14 +1000 Date: Fri, 9 Jun 1995 18:12:14 +1000 From: Bruce Evans Message-Id: <199506090812.SAA23942@godzilla.zeta.org.au> To: bugs@FreeBSD.org, dillon@best.com Subject: Re: connect() bug found and fixed (uninitialized pointer) Sender: bugs-owner@FreeBSD.org Precedence: bulk > * have noticed that sprintf() seems to need its arguments > cast to the exact type spected by the '%' control > elements, as reported in warnings if you compile something > -Wall (you have no warnings if you do not use -Wall). > Integer-type to integer-type casts are required... for > example, char to int for %d, int to char for %c, time_t, > gid_t, etc... not sure why. This broke wu-ftpd and a > couple of other programs. As best as I can tell, > something gets confused and the parameter offsets > get skewed, causing corruption when a bad pointer > (due to the skew) is dereferenced. Runtime problems are most likely caused by %d or %ld format specifiers mismatched with quad_t arguments, e.g., off_t's. quad_t's should be printed in format %qd. Casts shouldn't normally be used except for pointers. Pointer types should be cast to (void *) and printed in format %p. -Wall finds most mismatches to give you some chance of detecting int vs. long mismatches but it is sloppy about pointers. Bruce