fix inifinite loop due to broken symlink and new requires in git-svn
This commit is contained in:
parent
0338f401b4
commit
ffa0047cf6
2 changed files with 52 additions and 1 deletions
39
git-infinite-loop.patch
Normal file
39
git-infinite-loop.patch
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
diff --git a/refs.c b/refs.c
|
||||
index 67d6745..ddb9a77 100644
|
||||
--- a/refs.c
|
||||
+++ b/refs.c
|
||||
@@ -1422,6 +1422,7 @@ static struct ref_dir *get_loose_refs(struct ref_cache *refs)
|
||||
/* We allow "recursive" symbolic refs. Only within reason, though */
|
||||
#define MAXDEPTH 5
|
||||
#define MAXREFLEN (1024)
|
||||
+#define MAXRETRIES 5
|
||||
|
||||
/*
|
||||
* Called by resolve_gitlink_ref_recursive() after it failed to read
|
||||
@@ -1576,6 +1577,7 @@ const char *resolve_ref_unsafe(const char *refname, int resolve_flags, unsigned
|
||||
struct stat st;
|
||||
char *buf;
|
||||
int fd;
|
||||
+ int retries = 0;
|
||||
|
||||
if (--depth < 0) {
|
||||
errno = ELOOP;
|
||||
@@ -1612,7 +1614,8 @@ const char *resolve_ref_unsafe(const char *refname, int resolve_flags, unsigned
|
||||
if (S_ISLNK(st.st_mode)) {
|
||||
len = readlink(path, buffer, sizeof(buffer)-1);
|
||||
if (len < 0) {
|
||||
- if (errno == ENOENT || errno == EINVAL)
|
||||
+ if ((errno == ENOENT || errno == EINVAL) &&
|
||||
+ retries++ < MAXRETRIES)
|
||||
/* inconsistent with lstat; retry */
|
||||
goto stat_ref;
|
||||
else
|
||||
@@ -1645,7 +1648,7 @@ const char *resolve_ref_unsafe(const char *refname, int resolve_flags, unsigned
|
||||
*/
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
- if (errno == ENOENT)
|
||||
+ if (errno == ENOENT && retries++ < MAXRETRIES)
|
||||
/* inconsistent with lstat; retry */
|
||||
goto stat_ref;
|
||||
else
|
||||
Loading…
Add table
Add a link
Reference in a new issue