fchdir: fix off-by-one bug in previous patch
authorEric Blake <ebb9@byu.net>
Tue, 1 Sep 2009 16:06:44 +0000 (10:06 -0600)
committerEric Blake <ebb9@byu.net>
Tue, 1 Sep 2009 19:08:38 +0000 (13:08 -0600)
* lib/fchdir.c (rpl_fstat): Use correct bounds.
(_gl_unregister_fd): Delete useless if.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
lib/fchdir.c

index 223a0c6..b04c7a9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-09-01  Eric Blake  <ebb9@byu.net>
+
+       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  <berrange@redhat.com>
 
        maint.mk: sort the list of syntax-check rules
index cedbcde..170505f 100644 (file)
@@ -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);
 }