Skip to content

Commit

Permalink
Prevent pointer to an out-of-scope local variable
Browse files Browse the repository at this point in the history
`show_str` could be a pointer to a local variable in stack
which is out-of-scope by the time
`return (snprintf(buf, buflen, "%s\n", show_str));`
is called.

Reviewed-by: Tony Hutter <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Tomohiro Kusumi <[email protected]>
Closes openzfs#8924 
Closes openzfs#8940
  • Loading branch information
kusumi authored and behlendorf committed Jun 21, 2019
1 parent accd6d9 commit 9585497
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions module/zfs/zfs_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ zprop_sysfs_show(const char *attr_name, const zprop_desc_t *property,
char *buf, size_t buflen)
{
const char *show_str;
char number[32];

/* For dataset properties list the dataset types that apply */
if (strcmp(attr_name, "datasets") == 0 &&
Expand Down Expand Up @@ -291,8 +292,6 @@ zprop_sysfs_show(const char *attr_name, const zprop_desc_t *property,
} else if (strcmp(attr_name, "values") == 0) {
show_str = property->pd_values ? property->pd_values : "";
} else if (strcmp(attr_name, "default") == 0) {
char number[32];

switch (property->pd_proptype) {
case PROP_TYPE_NUMBER:
(void) snprintf(number, sizeof (number), "%llu",
Expand Down

0 comments on commit 9585497

Please sign in to comment.