diff options
author | Thorsten Kukuk <kukuk@thkukuk.de> | 2004-09-22 09:37:46 +0000 |
---|---|---|
committer | Thorsten Kukuk <kukuk@thkukuk.de> | 2004-09-22 09:37:46 +0000 |
commit | 6e99aa00d23a68650fdd4fae01aab812dcfe10eb (patch) | |
tree | 0b929b30fa38ed1d402515fbf9d7d8cf6dcb5284 /modules/pam_group/pam_group.c | |
parent | e1f75a80821125170e23a9b920d138a4a952c708 (diff) | |
download | pam-6e99aa00d23a68650fdd4fae01aab812dcfe10eb.tar.gz pam-6e99aa00d23a68650fdd4fae01aab812dcfe10eb.tar.bz2 pam-6e99aa00d23a68650fdd4fae01aab812dcfe10eb.zip |
Relevant BUGIDs:
Purpose of commit:
Commit summary:
---------------
bugfix: Add rest of Steve Grubb's resource leak and other fixes
Diffstat (limited to 'modules/pam_group/pam_group.c')
-rw-r--r-- | modules/pam_group/pam_group.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/modules/pam_group/pam_group.c b/modules/pam_group/pam_group.c index 77c909d0..4b42506c 100644 --- a/modules/pam_group/pam_group.c +++ b/modules/pam_group/pam_group.c @@ -79,6 +79,12 @@ static void shift_bytes(char *mem, int from, int by) } } +/* This function should initially be called with buf = NULL. If + * an error occurs, the file descriptor is closed. Subsequent + * calls with a closed descriptor will cause buf to be deallocated. + * Therefore, always check buf after calling this to see if an error + * occurred. + */ static int read_field(int fd, char **buf, int *from, int *to) { /* is buf set ? */ @@ -126,6 +132,7 @@ static int read_field(int fd, char **buf, int *from, int *to) i = read(fd, *to + *buf, PAM_GROUP_BUFLEN - *to); if (i < 0) { _log_err("error reading " PAM_GROUP_CONF); + close(fd); return -1; } else if (!i) { close(fd); @@ -165,6 +172,7 @@ static int read_field(int fd, char **buf, int *from, int *to) } else { _log_err("internal error in " __FILE__ " at line %d", __LINE__ ); + close(fd); return -1; } break; |