Re: malloc in libssl/src/apps

2014-05-05 Thread Alexander Hall
On May 6, 2014 1:34:01 AM CEST, Matthew Dempsky wrote: >On Mon, May 5, 2014 at 3:56 PM, Alexander Hall >wrote: >> I believe a similar situation could appear with not explicitly >initialized >> global or static declarations, e.g. in >> sbin/fsirand/fsirand.c: >> >> fsirand(char *device) >> { >>

Questions about C (was: Re: malloc in libssl/src/apps)

2014-05-05 Thread Jérémie Courrèges-Anglas
Matthew Dempsky writes: > On Mon, May 5, 2014 at 3:56 PM, Alexander Hall wrote: >> I believe a similar situation could appear with not explicitly initialized >> global or static declarations, e.g. in >> sbin/fsirand/fsirand.c: >> >> fsirand(char *device) >> { >> ... >> static cha

Re: malloc in libssl/src/apps

2014-05-05 Thread Matthew Dempsky
On Mon, May 5, 2014 at 3:56 PM, Alexander Hall wrote: > I believe a similar situation could appear with not explicitly initialized > global or static declarations, e.g. in > sbin/fsirand/fsirand.c: > > fsirand(char *device) > { > ... > static char *inodebuf; This is safe too: C re

Re: malloc in libssl/src/apps

2014-05-05 Thread Alexander Hall
On 05/06/14 00:10, Matthew Dempsky wrote: On Sun, May 4, 2014 at 8:26 PM, Jean-Philippe Ouellet wrote: On Sun, May 04, 2014 at 11:30:40PM +0200, Alexander Hall wrote: NULL theoretically could be != 0 Umm... short of something like: #undef NULL #define NULL "I'm silly and want to br

Re: malloc in libssl/src/apps

2014-05-05 Thread Matthew Dempsky
On Sun, May 4, 2014 at 8:26 PM, Jean-Philippe Ouellet wrote: > On Sun, May 04, 2014 at 11:30:40PM +0200, Alexander Hall wrote: >> NULL theoretically could be != 0 > > Umm... short of something like: > #undef NULL > #define NULL "I'm silly and want to break everything" > or something, I don

Re: malloc in libssl/src/apps

2014-05-05 Thread Jean-Philippe Ouellet
On Mon, May 05, 2014 at 07:31:34PM +1000, Joel Sing wrote: > > This one is calloc, not reallocarray, so unless I'm seriously missing > > something obvious here, it is indeed zero'd, no? > > Run the following before and after your change: Ah, yep. Can't believe I missed that (along with all the ot

Re: malloc in libssl/src/apps

2014-05-05 Thread Joel Sing
On Mon, 5 May 2014, Jean-Philippe Ouellet wrote: > On Mon, May 05, 2014 at 11:12:00AM +1000, Joel Sing wrote: > > > - i = 0; > > > if (arg->count == 0) { > > > arg->count = 20; > > > - arg->data = (char **)malloc(sizeof(char *) * arg->count); > > > + arg->data

Re: malloc in libssl/src/apps

2014-05-04 Thread patrick keshishian
On Sun, May 04, 2014 at 03:50:06PM -0400, Jean-Philippe Ouellet wrote: > On Sun, May 04, 2014 at 12:17:16PM -0600, Theo de Raadt wrote: > > We are going to completely ignore diffs which change multiple idioms > > at once. > > Okay. > > > That is how mistakes get made. > > Yep, more true than I r

Re: malloc in libssl/src/apps

2014-05-04 Thread Jean-Philippe Ouellet
On Mon, May 05, 2014 at 11:12:00AM +1000, Joel Sing wrote: > > - i = 0; > > if (arg->count == 0) { > > arg->count = 20; > > - arg->data = (char **)malloc(sizeof(char *) * arg->count); > > + arg->data = calloc(arg->count, sizeof(char *)); > > } > > - for (

Re: malloc in libssl/src/apps

2014-05-04 Thread Jean-Philippe Ouellet
On Sun, May 04, 2014 at 11:30:40PM +0200, Alexander Hall wrote: > NULL theoretically could be != 0 Umm... short of something like: #undef NULL #define NULL "I'm silly and want to break everything" or something, I don't see when that'd be the case. According to ISO/IEC 9899:1999 TC3 (n1256

Re: malloc in libssl/src/apps

2014-05-04 Thread Joel Sing
On Mon, 5 May 2014, Jean-Philippe Ouellet wrote: > On Sun, May 04, 2014 at 12:17:16PM -0600, Theo de Raadt wrote: > > We are going to completely ignore diffs which change multiple idioms > > at once. > > Okay. > > > That is how mistakes get made. > > Yep, more true than I realized. FWIW I already

Re: malloc in libssl/src/apps

2014-05-04 Thread Andres Perera
On Sun, May 4, 2014 at 5:00 PM, Alexander Hall wrote: > On 05/04/14 21:50, Jean-Philippe Ouellet wrote: >> >> On Sun, May 04, 2014 at 12:17:16PM -0600, Theo de Raadt wrote: >>> >>> We are going to completely ignore diffs which change multiple idioms >>> at once. >> >> >> Okay. >> >>> That is how m

Re: malloc in libssl/src/apps

2014-05-04 Thread Alexander Hall
On 05/04/14 21:50, Jean-Philippe Ouellet wrote: On Sun, May 04, 2014 at 12:17:16PM -0600, Theo de Raadt wrote: We are going to completely ignore diffs which change multiple idioms at once. Okay. That is how mistakes get made. Yep, more true than I realized. Here's a simpler one: Index:

Re: malloc in libssl/src/apps

2014-05-04 Thread Jean-Philippe Ouellet
On Sun, May 04, 2014 at 12:17:16PM -0600, Theo de Raadt wrote: > We are going to completely ignore diffs which change multiple idioms > at once. Okay. > That is how mistakes get made. Yep, more true than I realized. Here's a simpler one: Index: apps.c =

Re: malloc in libssl/src/apps

2014-05-04 Thread Theo de Raadt
We are going to completely ignore diffs which change multiple idioms at once. That is how mistakes get made. > On Sun, May 04, 2014 at 02:38:40AM -0400, Jean-Philippe Ouellet wrote: > > Hello, > > > > I've gone through lib/libssl/src/apps with the goal of making {m,c,re}alloc > > uses more idiom

Re: malloc in libssl/src/apps

2014-05-04 Thread patrick keshishian
On Sun, May 04, 2014 at 02:38:40AM -0400, Jean-Philippe Ouellet wrote: > Hello, > > I've gone through lib/libssl/src/apps with the goal of making {m,c,re}alloc > uses more idiomatic, adding error checking in some places where missing, > and some minor style unification. > > Feedback appreciated,

Re: malloc in libssl/src/apps

2014-05-04 Thread patrick keshishian
On Sun, May 04, 2014 at 01:26:18AM -0700, Philip Guenther wrote: > On Sunday, May 4, 2014, patrick keshishian wrote: > > > On Sun, May 04, 2014 at 12:29:59AM -0700, Philip Guenther wrote: > > > On Sun, May 4, 2014 at 12:21 AM, patrick keshishian > > > > > >wrote: > > > > > > > On Sun, May 04, 2

Re: malloc in libssl/src/apps

2014-05-04 Thread Philip Guenther
On Sunday, May 4, 2014, Marc Espie wrote: > See guenther(2) for a more serious answer). > Thank you, but I've always thought of myself as belonging in section 6... Philip Guenther

Re: malloc in libssl/src/apps

2014-05-04 Thread Philip Guenther
On Sunday, May 4, 2014, patrick keshishian wrote: > On Sun, May 04, 2014 at 12:29:59AM -0700, Philip Guenther wrote: > > On Sun, May 4, 2014 at 12:21 AM, patrick keshishian > > > >wrote: > > > > > On Sun, May 04, 2014 at 02:38:40AM -0400, Jean-Philippe Ouellet wrote: > > > > > ... > > > > > > -

Re: malloc in libssl/src/apps

2014-05-04 Thread Marc Espie
On Sun, May 04, 2014 at 12:21:04AM -0700, patrick keshishian wrote: > why not use calloc(2)? Because it doesn't exist ? (hint: the 2 in calloc(2) is the manual section. There is no calloc system call, therefore you can't be right. See guenther(2) for a more serious answer).

Re: malloc in libssl/src/apps

2014-05-04 Thread patrick keshishian
On Sun, May 04, 2014 at 12:29:59AM -0700, Philip Guenther wrote: > On Sun, May 4, 2014 at 12:21 AM, patrick keshishian > wrote: > > > On Sun, May 04, 2014 at 02:38:40AM -0400, Jean-Philippe Ouellet wrote: > > > ... > > > > - if ((irow = (char **)malloc(sizeof(char *) * > > > -

Re: malloc in libssl/src/apps

2014-05-04 Thread Philip Guenther
On Sun, May 4, 2014 at 12:21 AM, patrick keshishian wrote: > On Sun, May 04, 2014 at 02:38:40AM -0400, Jean-Philippe Ouellet wrote: > ... > > - if ((irow = (char **)malloc(sizeof(char *) * > > - (DB_NUMBER + 1))) == NULL) { > > + irow = reallocarray(NULL, D

Re: malloc in libssl/src/apps

2014-05-04 Thread patrick keshishian
On Sun, May 04, 2014 at 02:38:40AM -0400, Jean-Philippe Ouellet wrote: > Hello, > > I've gone through lib/libssl/src/apps with the goal of making {m,c,re}alloc > uses more idiomatic, adding error checking in some places where missing, > and some minor style unification. > > Feedback appreciated,

malloc in libssl/src/apps

2014-05-03 Thread Jean-Philippe Ouellet
Hello, I've gone through lib/libssl/src/apps with the goal of making {m,c,re}alloc uses more idiomatic, adding error checking in some places where missing, and some minor style unification. Feedback appreciated, better patches to come after the semester ends. Index: apps.c =