diff options
author | Wayne Davison <wayned@users.sourceforge.net> | 2004-05-11 21:45:36 +0000 |
---|---|---|
committer | Wayne Davison <wayned@users.sourceforge.net> | 2004-05-11 21:45:36 +0000 |
commit | 1ec2b5c096e4a7a47bff2f65fe3dce104a063dec (patch) | |
tree | 3b4ef8881171659880c0e802e7e408ba9382ed3c | |
parent | c00fdaa3f09ab95310ae87251d8dcc7507f45a18 (diff) | |
download | zsh-1ec2b5c096e4a7a47bff2f65fe3dce104a063dec.tar.gz zsh-1ec2b5c096e4a7a47bff2f65fe3dce104a063dec.tar.xz zsh-1ec2b5c096e4a7a47bff2f65fe3dce104a063dec.zip |
Fix the potential for an infinite loop in lockhistfile() if the
link() calls fails for some other reason than EEXIST.
-rw-r--r-- | Src/hist.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Src/hist.c b/Src/hist.c index 0e0c4be98..e0b0475fb 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -2139,11 +2139,13 @@ lockhistfile(char *fn, int keep_trying) write(fd, tmpfile+len+1, strlen(tmpfile+len+1)); close(fd); while (link(tmpfile, lockfile) < 0) { - if (stat(lockfile, &sb) < 0) { + if (errno != EEXIST || !keep_trying) + ; + else if (stat(lockfile, &sb) < 0) { if (errno == ENOENT) continue; } - else if (keep_trying) { + else { if (time(NULL) - sb.st_mtime < 10) sleep(1); else |