mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] Return rv if memory is not 'calloc'ed in getgrent_a
@ 2015-05-01 12:17 Kevin Bowling
  2015-05-01 15:50 ` Rich Felker
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Bowling @ 2015-05-01 12:17 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 772 bytes --]

From 714875b1a614c4ac3b7a04a9d419b7f57d28e336 Mon Sep 17 00:00:00 2001
From: Kevin Bowling <kevin.bowling@kev009.com>
Date: Fri, 1 May 2015 05:11:12 -0700
Subject: [PATCH] Return rv if memory is not 'calloc'ed in getgrent_a

---
 src/passwd/getgrent_a.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/passwd/getgrent_a.c b/src/passwd/getgrent_a.c
index ecd2f2e..80fbc42 100644
--- a/src/passwd/getgrent_a.c
+++ b/src/passwd/getgrent_a.c
@@ -48,7 +48,7 @@ int __getgrent_a(FILE *f, struct group *gr, char **line,
size_t *size, char ***m
                rv = errno;
                free(*line);
                *line = 0;
-               return 0;
+               return rv;
        }
        if (*mems) {
                mem[0][0] = mems;
--
2.3.7

[-- Attachment #2: Type: text/html, Size: 983 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Return rv if memory is not 'calloc'ed in getgrent_a
  2015-05-01 12:17 [PATCH] Return rv if memory is not 'calloc'ed in getgrent_a Kevin Bowling
@ 2015-05-01 15:50 ` Rich Felker
  2015-05-01 16:34   ` Rich Felker
  0 siblings, 1 reply; 3+ messages in thread
From: Rich Felker @ 2015-05-01 15:50 UTC (permalink / raw)
  To: musl

On Fri, May 01, 2015 at 05:17:37AM -0700, Kevin Bowling wrote:
> >From 714875b1a614c4ac3b7a04a9d419b7f57d28e336 Mon Sep 17 00:00:00 2001
> From: Kevin Bowling <kevin.bowling@kev009.com>
> Date: Fri, 1 May 2015 05:11:12 -0700
> Subject: [PATCH] Return rv if memory is not 'calloc'ed in getgrent_a
> 
> ---
>  src/passwd/getgrent_a.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/passwd/getgrent_a.c b/src/passwd/getgrent_a.c
> index ecd2f2e..80fbc42 100644
> --- a/src/passwd/getgrent_a.c
> +++ b/src/passwd/getgrent_a.c
> @@ -48,7 +48,7 @@ int __getgrent_a(FILE *f, struct group *gr, char **line,
> size_t *size, char ***m
>                 rv = errno;
>                 free(*line);
>                 *line = 0;
> -               return 0;
> +               return rv;
>         }
>         if (*mems) {
>                 mem[0][0] = mems;
> --
> 2.3.7

There's definitely a bug here but I don't think this patch fixes it.
The exit code, which needs to be run, is still bypassed. There needs
to be a "goto end" or similar instead of return, I think.

Rich


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Return rv if memory is not 'calloc'ed in getgrent_a
  2015-05-01 15:50 ` Rich Felker
@ 2015-05-01 16:34   ` Rich Felker
  0 siblings, 0 replies; 3+ messages in thread
From: Rich Felker @ 2015-05-01 16:34 UTC (permalink / raw)
  To: musl

On Fri, May 01, 2015 at 11:50:10AM -0400, Rich Felker wrote:
> On Fri, May 01, 2015 at 05:17:37AM -0700, Kevin Bowling wrote:
> > >From 714875b1a614c4ac3b7a04a9d419b7f57d28e336 Mon Sep 17 00:00:00 2001
> > From: Kevin Bowling <kevin.bowling@kev009.com>
> > Date: Fri, 1 May 2015 05:11:12 -0700
> > Subject: [PATCH] Return rv if memory is not 'calloc'ed in getgrent_a
> > 
> > ---
> >  src/passwd/getgrent_a.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/src/passwd/getgrent_a.c b/src/passwd/getgrent_a.c
> > index ecd2f2e..80fbc42 100644
> > --- a/src/passwd/getgrent_a.c
> > +++ b/src/passwd/getgrent_a.c
> > @@ -48,7 +48,7 @@ int __getgrent_a(FILE *f, struct group *gr, char **line,
> > size_t *size, char ***m
> >                 rv = errno;
> >                 free(*line);
> >                 *line = 0;
> > -               return 0;
> > +               return rv;
> >         }
> >         if (*mems) {
> >                 mem[0][0] = mems;
> > --
> > 2.3.7
> 
> There's definitely a bug here but I don't think this patch fixes it.
> The exit code, which needs to be run, is still bypassed. There needs
> to be a "goto end" or similar instead of return, I think.

Should be fixed in commit 58fa856960d3073bcf84adac8e8bd6c555674271.
Let me know if you think there's still a problem. Thanks for the bug
report!

Rich


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-05-01 16:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-01 12:17 [PATCH] Return rv if memory is not 'calloc'ed in getgrent_a Kevin Bowling
2015-05-01 15:50 ` Rich Felker
2015-05-01 16:34   ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).