Bugtraq mailing list archives
Re: local root on linux 2.2.15
From: pfaffben () MSU EDU (Ben Pfaff)
Date: Thu, 15 Jun 2000 22:43:10 -0400
Peter da Silva <peter () SCARYDEVIL ORG> writes:
In article <87bt184i7z.fsf () arabella intern opera no> you write:cap_user_header_t header; cap_user_data_t data;
[...]
header = malloc(sizeof (cap_user_header_t) ); data = malloc(sizeof (cap_user_data_t) );
The comp.lang.c approved version of these statements would read: header = malloc (sizeof *header); data = malloc (sizeof *data); given that the declarations were actually cap_user_header_t *header; cap_user_data_t *data; or that cap_user_header_t and cap_user_data_t were typedefs of pointer types. There's a couple of reasons to do it this way: * If you ever change the type that `header' or `data' points to, for whatever reason, it's not necessary to change the malloc() call as well. This is convenient and a handy safeguard against forgetting to change all your malloc() calls. * Taking the size of an object makes your sizeof call more similar to your declaration, which makes writing the statement less error-prone. However, if the declarations were as above, with Peter's statements, there is something wrong. It is almost certainly a mistake to use the same type for both the pointer and the pointed-to object, as Peter's suggested code implies; the actual equivalent of his code using sizeof on an object would be this: header = malloc (sizeof header); data = malloc (sizeof data); Though I do not know what a cap_user_header_t or a cap_user_data_t is, I can hardly believe that this is correct. -- "Welcome to the Slippery Slope. Here is your handbasket. Say, can you work 70 hours this week?" --Ron Mansolino
Current thread:
- XFree86: xdm flaw; present in kdm, (continued)
- XFree86: xdm flaw; present in kdm Chris Evans (Jun 19)
- XFree86: xdm xdmcp code in wdm also Brian Russo (Jun 20)
- Re: XFree86: xdm xdmcp code in wdm also Jerome ALET (Jun 20)
- Problems with "kon2" package Chris Evans (Jun 19)
- [TL-Security-Announce] Linux Kernel TLSA2000013-1 Roger Luethi (Jun 19)
- Re: [TL-Security-Announce] Linux Kernel TLSA2000013-1 Gregory Neil Shapiro (Jun 28)
- CERT Advisory CA-2000-12 Roman Drahtmueller (Jun 19)
- Re: local root on linux 2.2.15 Joseph Gooch (Jun 15)
- Conectiva Linux Security Announcement - ZOPE Sergio Bruder (Jun 16)