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 = calloc(arg-count,

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 other

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 jean-phili...@ouellet.biz 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

Re: malloc in libssl/src/apps

2014-05-05 Thread Matthew Dempsky
On Mon, May 5, 2014 at 3:56 PM, Alexander Hall alexan...@beard.se 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

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

2014-05-05 Thread Jérémie Courrèges-Anglas
Matthew Dempsky matt...@dempsky.org writes: On Mon, May 5, 2014 at 3:56 PM, Alexander Hall alexan...@beard.se 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) {

Re: malloc in libssl/src/apps

2014-05-05 Thread Alexander Hall
On May 6, 2014 1:34:01 AM CEST, Matthew Dempsky matt...@dempsky.org wrote: On Mon, May 5, 2014 at 3:56 PM, Alexander Hall alexan...@beard.se wrote: I believe a similar situation could appear with not explicitly initialized global or static declarations, e.g. in sbin/fsirand/fsirand.c:

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, better

Re: malloc in libssl/src/apps

2014-05-04 Thread Philip Guenther
On Sun, May 4, 2014 at 12:21 AM, patrick keshishian sids...@boxsoft.comwrote: 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 =

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 sids...@boxsoft.comwrote: 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 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 Philip Guenther
On Sunday, May 4, 2014, patrick keshishian sids...@boxsoft.com 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 sids...@boxsoft.comjavascript:; wrote: On Sun, May 04, 2014 at 02:38:40AM -0400, Jean-Philippe

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 sids...@boxsoft.com 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 sids...@boxsoft.comjavascript:;

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, better

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 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 Andres Perera
On Sun, May 4, 2014 at 5:00 PM, Alexander Hall alexan...@beard.se 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

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 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 (i = 0; i

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 realized.