aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Walker <walker.aj325_gmail.com>2021-04-20 19:34:44 +0000
committerRyan Moeller <freqlabs@FreeBSD.org>2021-04-20 19:39:56 +0000
commitdd559118ab3f065ae230b324c3fe4bb1c9b7ca56 (patch)
tree844ed37938857c652b81f56c4b6e379d05880650
parentb8be8094958a01255f5430bd6a36ff936bdd53c3 (diff)
downloadsrc-dd559118ab3f065ae230b324c3fe4bb1c9b7ca56.tar.gz
src-dd559118ab3f065ae230b324c3fe4bb1c9b7ca56.zip
Fix leak in libc NFSv4 flags parsing
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 MFC after: 3 days Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D29871
-rw-r--r--lib/libc/posix1e/acl_support_nfs4.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libc/posix1e/acl_support_nfs4.c b/lib/libc/posix1e/acl_support_nfs4.c
index 3962eaa6daa8..92ec666b2313 100644
--- a/lib/libc/posix1e/acl_support_nfs4.c
+++ b/lib/libc/posix1e/acl_support_nfs4.c
@@ -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;
@@ -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);
}