diff options
author | Ray Strode <rstrode@redhat.com> | 2007-12-01 01:32:05 +0000 |
---|---|---|
committer | Ray Strode <halfline@src.gnome.org> | 2007-12-01 01:32:05 +0000 |
commit | 7936d94a273cdb0b09d6f7520a9d65a9a455f5ff (patch) | |
tree | f900d5a1cbd423cc4119990dc5ed08f82eaa7a63 /common | |
parent | 4e85b11eb11c630bd02a980ee18b2477341dd78e (diff) | |
download | gdm-7936d94a273cdb0b09d6f7520a9d65a9a455f5ff.tar.gz |
Fix some problems in the previous commit, spotted by Mike Oliver
2007-11-30 Ray Strode <rstrode@redhat.com>
Fix some problems in the previous commit, spotted by
Mike Oliver <Mike.Oliver@sun.com>
* common/gdm-common.[ch] (gdm_generate_random_bytes):
don't leak fd
(_read_bytes): initialize bytes_left_to_read
svn path=/trunk/; revision=5535
Diffstat (limited to 'common')
-rw-r--r-- | common/gdm-common.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/common/gdm-common.c b/common/gdm-common.c index 014c464e..a43ccff9 100644 --- a/common/gdm-common.c +++ b/common/gdm-common.c @@ -295,6 +295,7 @@ _read_bytes (int fd, size_t total_bytes_read = 0; gboolean premature_eof; + bytes_left_to_read = number_of_bytes; premature_eof = FALSE; do { size_t bytes_read = 0; @@ -359,6 +360,7 @@ gdm_generate_random_bytes (gsize size, G_FILE_ERROR, g_file_error_from_errno (errno), "%s", g_strerror (errno)); + close (fd); return NULL; } @@ -367,6 +369,7 @@ gdm_generate_random_bytes (gsize size, G_FILE_ERROR, g_file_error_from_errno (ENODEV), _("/dev/urandom is not a character device")); + close (fd); return NULL; } @@ -375,8 +378,10 @@ gdm_generate_random_bytes (gsize size, if (!_read_bytes (fd, bytes, size, &read_error)) { g_propagate_error (error, read_error); g_free (bytes); + close (fd); return NULL; } + close (fd); return bytes; } |