public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* size_t cast in libssp
@ 2010-10-05  9:54 angie
  2010-10-05 10:06 ` Andreas Schwab
  0 siblings, 1 reply; 2+ messages in thread
From: angie @ 2010-10-05  9:54 UTC (permalink / raw)
  To: gcc-bugs

After some casual analysis, I noticed that libssp (in gets-chk.c) we 
were doing:

 if (slen >= (size_t) INT_MAX)
    return gets (s);

  if (slen <= 8192)
    buf = alloca (slen + 1);
  else
    buf = malloc (slen + 1);
  if (buf == NULL)
    return gets (s);

What's the reason behind casting with size_t for INT_MAX, it seems to 
be a design
error, there is no guarantee that INT_MAX is a valid size_t. If we 
want to limit it
to size_t, we'd instead want a macro finding the minimum of INT_MAX 
and SIZE_MAX,
thereby rendering the whole cast unnecessary and potentially badly 
thought out.

Please get back to me at this address regarding this so that we may 
discuss future changes

Thanks!


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-10-05 10:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-05  9:54 size_t cast in libssp angie
2010-10-05 10:06 ` Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).