On Fri, 7 Jan 2011 12:01:24 -0600 Shirish Pargaonkar <shirishpargaonkar@xxxxxxxxx> wrote: > On Wed, Jan 5, 2011 at 9:37 AM, Jeff Layton <jlayton@xxxxxxxxx> wrote: > > If cifs.upcall is passed an invalid argument then it will "goto out". > > The decoded_args struct however is uninitialized at that point so it > > will usually segfault when trying to free fields in it. Move the > > initialization up in the function. > > > > Signed-off-by: Jeff Layton <jlayton@xxxxxxxxx> > > --- > > cifs.upcall.c | 3 +-- > > 1 files changed, 1 insertions(+), 2 deletions(-) > > > > diff --git a/cifs.upcall.c b/cifs.upcall.c > > index 1ffcd7c..34b0638 100644 > > --- a/cifs.upcall.c > > +++ b/cifs.upcall.c > > @@ -677,6 +677,7 @@ int main(const int argc, char *const argv[]) > > const char *oid; > > > > hostbuf[0] = '\0'; > > + memset(&arg, 0, sizeof(arg)); > > > > openlog(prog, 0, LOG_DAEMON); > > > > @@ -731,8 +732,6 @@ int main(const int argc, char *const argv[]) > > goto out; > > } > > > > - memset(&arg, 0, sizeof(arg)); > > - > > have = decode_key_description(buf, &arg); > > SAFE_FREE(buf); > > if ((have & DKD_MUSTHAVE_SET) != DKD_MUSTHAVE_SET) { > > -- > > 1.7.3.4 > > > > -- > > To unsubscribe from this list: send the line "unsubscribe linux-cifs" in > > the body of a message to majordomo@xxxxxxxxxxxxxxx > > More majordomo info at http://vger.kernel.org/majordomo-info.html > > > > Looks correct but something like would do the same (and save a memset call?) > > struct decoded_args arg = {0}; I used to use a c99 initializer for this, but changed it in this commit due to some gcc warnings: http://git.samba.org/?p=cifs-utils.git;a=commitdiff;h=986923d1317faf82253996079ddab5d43ae44d29 I don't think it matters much for efficiency's sake. The code still has to zero out the struct regardless. -- Jeff Layton <jlayton@xxxxxxxxx> -- To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html