Patch: Sendmail 5.61 core dumps on long lists

Andy Linton Andy.Linton at comp.vuw.ac.nz
Wed Jun 6 11:27:31 AEST 1990


In article <60685 at lll-winken.LLNL.GOV>, casey at gauss.llnl.gov (Casey
Leedom) writes:
|> 
|>   No, the problem was because the test was:
|> 
|> 	sizeof(foo) - int expression < 0
|> 
|> Sizeof returns unsigned which gives us:
|> 
|> 	unsigned expression - int expression < 0
|> 
|> which type promoting turns into:
|> 
|> 	unsigned expression < 0
|> 
|> which can never be true.  As far as I know ANSI C has not changed anything
|> that would affect this.

'sizeof' used to return an 'int' (see page 126, The C Programming
Language, Kernighan and Ritchie, 1978) and that while Harbison and
Steele (C: A Reference Manual, First Edition, Page 154, 1984)
recommended "that the result of the 'sizeof' operator be either of type
'unsigned int' or of type 'unsigned long'at the discretion of the
implementor" it wasn't standardised at that time.

In Harbison and Steele, C: A Reference Manual, Second Edition, Page 273
they say in referring to Draft Proposed ANSI C that "the result of the
'sizeof' operator may be of type 'unsigned int' or 'unsigned long'. The
type chosen by and implementation is defined as 'size_t' in the standard
header file 'stddef.h'." They also say on Page 299 that the draft
standard requires "the return type of 'strlen' to be 'size_t'". 

The point I was making was that because the type returned by 'sizeof'
and 'strlen' is now 'size_t' which is now *defined* to be 'unsigned int'
or 'unsigned long' the test fails for the reason Casey gives. Previously
the values returned by 'sizeof' and 'strlen' were implementation
dependent and the original test was written in a non-portable manner.



More information about the Comp.bugs.4bsd.ucb-fixes mailing list