Skip to content

Commit

Permalink
src/useradd.c: set_defaults(): Fix FILE* leak
Browse files Browse the repository at this point in the history
Report:
> shadow-4.15.0/src/useradd.c:575:2: alloc_fn: Storage is returned from allocation function "fdopen".
> shadow-4.15.0/src/useradd.c:575:2: var_assign: Assigning: "ofp" = storage returned from "fdopen(ofd, "w")".
> shadow-4.15.0/src/useradd.c:734:2: leaked_storage: Variable "ofp" going out of scope leaks the storage it points to.
> 732|           }
> 733|
> 734|->         return ret;
> 735|   }
> 736|

Link: <https://issues.redhat.com/browse/RHEL-35383>
Reported-by: Iker Pedrosa <[email protected]>
Reviewed-by: Iker Pedrosa <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
  • Loading branch information
alejandro-colomar committed May 17, 2024
1 parent e7d1508 commit 1ee066a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/useradd.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,8 @@ static int set_defaults (void)
fprintf (stderr,
_("%s: line too long in %s: %s..."),
Prog, default_file, buf);
(void) fclose (ifp);
fclose(ifp);
fclose(ofp);
goto err_free_def;
}
}
Expand Down

0 comments on commit 1ee066a

Please sign in to comment.