diff options
author | Jeremy Allison <jra@samba.org> | 1998-11-12 03:50:29 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 1998-11-12 03:50:29 +0000 |
commit | aba85cb152e0baf686e879643926de0fa2fce80f (patch) | |
tree | ccbf6f74b39b65ab532d879f63e68ee8e978b522 /source3 | |
parent | 5d5ed9841481a035f4420bfdfc2448fb1c76d318 (diff) | |
download | samba-aba85cb152e0baf686e879643926de0fa2fce80f.tar.gz samba-aba85cb152e0baf686e879643926de0fa2fce80f.tar.bz2 samba-aba85cb152e0baf686e879643926de0fa2fce80f.zip |
Fix fd leak in error condition in grantpt code case.
Jeremy.
(This used to be commit 22df2dae30b815f1c86bd21ac0ccf02da5b85eba)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/smbd/chgpasswd.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/source3/smbd/chgpasswd.c b/source3/smbd/chgpasswd.c index 4369573fe8..52ca364070 100644 --- a/source3/smbd/chgpasswd.c +++ b/source3/smbd/chgpasswd.c @@ -71,6 +71,8 @@ static int findpty(char **slave) *slave = ptsname(master); if (*slave == NULL) { DEBUG(0,("findpty: Unable to create master/slave pty pair.\n")); + /* Stop fd leak on error. */ + close(master); return -1; } else { DEBUG(10, ("findpty: Allocated slave pty %s\n", *slave)); @@ -81,7 +83,8 @@ static int findpty(char **slave) fstrcpy( line, "/dev/ptyXX" ); dirp = OpenDir(NULL, "/dev", False); - if (!dirp) return(-1); + if (!dirp) + return(-1); while ((dpname = ReadDirName(dirp)) != NULL) { if (strncmp(dpname, "pty", 3) == 0 && strlen(dpname) == 5) { DEBUG(3,("pty: try to open %s, line was %s\n", dpname, line ) ); @@ -89,10 +92,10 @@ static int findpty(char **slave) line[9] = dpname[4]; if ((master = open(line, O_RDWR)) >= 0) { DEBUG(3,("pty: opened %s\n", line ) ); - line[5] = 't'; - *slave = line; - CloseDir(dirp); - return (master); + line[5] = 't'; + *slave = line; + CloseDir(dirp); + return (master); } } } |