[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
canonicalize loop-detection failure
From: |
Jim Meyering |
Subject: |
canonicalize loop-detection failure |
Date: |
Fri, 28 Sep 2007 23:33:37 +0200 |
Thanks to Bob's buildbot, I spotted a problem with my recent change.
Without this, the test mentioned below would fail with a diagnostic
about "../s" not being found, rather than saying that it'd detected
a symlink loop. Here's the patch I'll push as soon as tests pass.
>From 05552c43d21f272e927663aae4bc810e17d4d785 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 28 Sep 2007 23:26:49 +0200
Subject: [PATCH] Fix canonicalize loop-detection corner case.
Do not attempt to stat the symlink values stored via seen_triple.
Without this, coreutils' tests/misc/readlink-fp-loop test would fail
on linux-2.6.18, (but not 2.6.22).
* lib/canonicalize.c (seen_triple): Use triple_compare_ino_str, not
triple_compare. The former compares dev,ino,filename, while the latter
would actually stat dirname(filename) when dev and ino were equal.
* lib/hash-triple.c: Install <string.h>.
(STREQ): Define.
(triple_compare_ino_str): New function.
* lib/hash-triple.h (triple_compare_ino_str): Declare it.
Signed-off-by: Jim Meyering <address@hidden>
---
ChangeLog | 14 ++++++++++++++
lib/canonicalize.c | 2 +-
lib/hash-triple.c | 11 +++++++++++
lib/hash-triple.h | 1 +
4 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 80a7159..44972ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2007-09-28 Jim Meyering <address@hidden>
+
+ Fix canonicalize loop-detection corner case.
+ Do not attempt to stat the symlink values stored via seen_triple.
+ Without this, coreutils' tests/misc/readlink-fp-loop test would fail
+ on linux-2.6.18, (but not 2.6.22).
+ * lib/canonicalize.c (seen_triple): Use triple_compare_ino_str, not
+ triple_compare. The former compares dev,ino,filename, while the latter
+ would actually stat dirname(filename) when dev and ino were equal.
+ * lib/hash-triple.c: Install <string.h>.
+ (STREQ): Define.
+ (triple_compare_ino_str): New function.
+ * lib/hash-triple.h (triple_compare_ino_str): Declare it.
+
2007-09-28 Eric Blake <address@hidden>
Enforce that AC_REPLACE_FUNCS files exist.
diff --git a/lib/canonicalize.c b/lib/canonicalize.c
index af2703c..bbf3855 100644
--- a/lib/canonicalize.c
+++ b/lib/canonicalize.c
@@ -135,7 +135,7 @@ seen_triple (Hash_table **ht, char const *filename, struct
stat const *st)
*ht = hash_initialize (initial_capacity,
NULL,
triple_hash,
- triple_compare,
+ triple_compare_ino_str,
triple_free);
if (*ht == NULL)
xalloc_die ();
diff --git a/lib/hash-triple.c b/lib/hash-triple.c
index 2644b5f..a65a4db 100644
--- a/lib/hash-triple.c
+++ b/lib/hash-triple.c
@@ -22,11 +22,14 @@
#include "hash-triple.h"
#include <stdlib.h>
+#include <string.h>
#include "hash-pjw.h"
#include "same.h"
#include "same-inode.h"
+#define STREQ(a, b) (strcmp ((a), (b)) == 0)
+
/* Hash an F_triple, and *do* consider the file name. */
size_t
triple_hash (void const *x, size_t table_size)
@@ -57,6 +60,14 @@ triple_compare (void const *x, void const *y)
return (SAME_INODE (*a, *b) && same_name (a->name, b->name)) ? true : false;
}
+bool
+triple_compare_ino_str (void const *x, void const *y)
+{
+ struct F_triple const *a = x;
+ struct F_triple const *b = y;
+ return (SAME_INODE (*a, *b) && STREQ (a->name, b->name)) ? true : false;
+}
+
/* Free an F_triple. */
void
triple_free (void *x)
diff --git a/lib/hash-triple.h b/lib/hash-triple.h
index 7abe970..51863c9 100644
--- a/lib/hash-triple.h
+++ b/lib/hash-triple.h
@@ -16,6 +16,7 @@ struct F_triple
extern size_t triple_hash (void const *x, size_t table_size);
extern size_t triple_hash_no_name (void const *x, size_t table_size);
extern bool triple_compare (void const *x, void const *y);
+extern bool triple_compare_ino_str (void const *x, void const *y);
extern void triple_free (void *x);
#endif
--
1.5.3.2.99.ge4b2-dirty
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- canonicalize loop-detection failure,
Jim Meyering <=