Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1500623
| From | Al Viro <viro@ZenIV.linux.org.uk> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: when to size_t for representing length instead of int ? |
| Date | 2016-10-14 01:40 +0200 |
| Message-ID | <srXLr-1KS-3@gated-at.bofh.it> (permalink) |
| References | <srWFH-180-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Fri, Oct 14, 2016 at 12:12:43AM +0200, none wrote: > Hello, > > I wanted to known the rules in coding guidelines concerning the use of > size_t. > It seems the signed int type is used most of the time for representing > string sizes, including in some parts written by Linus in /lib. > They’re can buffer overflows attack if ssize_t if larger than sizeof(int) > (though I agree this isn’t the only way, but at least it´s less error > prone). Huh? size_t is the type of sizoef result; ssize_t is its signed counterpart. > So is it guaranteed for all current and future cpu architectures the Linux > kernel support that ssize_t will always be equal to sizeof(int) ? Of course it isn't. Not true on any 64bit architecture we support... What attacks are, in your opinion, enabled by that fact? I'm sure that libc (and C standard) folks would be very interested, considering that e.g. strlen() is declared as function that takes a pointer to const char and returns size_t...
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
when to size_t for representing length instead of int ? none <ytrezq@sdf-eu.org> - 2016-10-14 00:30 +0200
Re: when to size_t for representing length instead of int ? Al Viro <viro@ZenIV.linux.org.uk> - 2016-10-14 01:40 +0200
Re: when to size_t for representing length instead of int ? none <ytrezq@sdf-eu.org> - 2016-10-16 04:10 +0200
csiph-web