Skip to content

Commit

Permalink
Fix leak in libc NFSv4 ACL flags parsing
Browse files Browse the repository at this point in the history
Free memory allocated by strdup() in parse_flags_verbose().

Submitted by:	Andrew Walker <walker.aj325_gmail.com>
Reported by:	valgrind
Reviewed by:	allanjude, freqlabs, rpokala
Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D29871

(cherry picked from commit dd55911)
  • Loading branch information
Andrew Walker authored and Ryan Moeller committed Apr 23, 2021
1 parent ab9104c commit 8845eea
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/libc/posix1e/acl_support_nfs4.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,10 @@ parse_flags_verbose(const char *strp, uint32_t *var,
int *try_compact)
{
int i, found, ever_found = 0;
char *str, *flag;
char *str, *flag, *to_free;

str = strdup(strp);
to_free = str;
*try_compact = 0;
*var = 0;

Expand All @@ -166,12 +167,12 @@ parse_flags_verbose(const char *strp, uint32_t *var,
"invalid flag \"%s\"", flags_name, flag);
else
*try_compact = 1;
free(str);
free(to_free);
return (-1);
}
}

free(str);
free(to_free);
return (0);
}

Expand Down

0 comments on commit 8845eea

Please sign in to comment.