From 0a9873c53517b88fe01a2678002b95574e433a03 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Tue, 1 Sep 2009 10:06:44 -0600 Subject: [PATCH] fchdir: fix off-by-one bug in previous patch * lib/fchdir.c (rpl_fstat): Use correct bounds. (_gl_unregister_fd): Delete useless if. Signed-off-by: Eric Blake --- ChangeLog | 6 ++++++ lib/fchdir.c | 5 ++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 223a0c65f3..b04c7a9f28 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-09-01 Eric Blake + + fchdir: fix off-by-one bug in previous patch + * lib/fchdir.c (rpl_fstat): Use correct bounds. + (_gl_unregister_fd): Delete useless if. + 2009-09-01 Daniel P. Berrange maint.mk: sort the list of syntax-check rules diff --git a/lib/fchdir.c b/lib/fchdir.c index cedbcde7fe..170505f157 100644 --- a/lib/fchdir.c +++ b/lib/fchdir.c @@ -93,8 +93,7 @@ _gl_unregister_fd (int fd) { if (fd >= 0 && fd < dirs_allocated) { - if (dirs[fd].name != NULL) - free (dirs[fd].name); + free (dirs[fd].name); dirs[fd].name = NULL; dirs[fd].saved_errno = ENOTDIR; } @@ -126,7 +125,7 @@ _gl_register_fd (int fd, const char *filename) int rpl_fstat (int fd, struct stat *statbuf) { - if (0 <= fd && fd <= dirs_allocated && dirs[fd].name != NULL) + if (0 <= fd && fd < dirs_allocated && dirs[fd].name != NULL) return stat (dirs[fd].name, statbuf); return fstat (fd, statbuf); } -- 2.30.2