summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2275d50)
raw | patch | inline | side by side (parent: 2275d50)
author | Jim Meyering <jim@meyering.net> | |
Sun, 24 Jun 2007 19:20:41 +0000 (21:20 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 27 Jun 2007 04:48:53 +0000 (21:48 -0700) |
I audited git for potential undetected write failures.
In the cases fixed below, the diagnostics I add mimic the diagnostics
used in surrounding code, even when that means not reporting
the precise strerror(errno) cause of the error.
Signed-off-by: Jim Meyering <jim@meyering.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
In the cases fixed below, the diagnostics I add mimic the diagnostics
used in surrounding code, even when that means not reporting
the precise strerror(errno) cause of the error.
Signed-off-by: Jim Meyering <jim@meyering.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-init-db.c | patch | blob | history | |
builtin-rerere.c | patch | blob | history | |
index-pack.c | patch | blob | history | |
refs.c | patch | blob | history |
diff --git a/builtin-init-db.c b/builtin-init-db.c
index 0be2d2ef6eec3e5830e893795cf9219851611859..976f47b3233cf0aba34e104bb4524aace40dccba 100644 (file)
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
return fdo;
}
status = copy_fd(fdi, fdo);
- close(fdo);
+ if (close(fdo) != 0)
+ return error("%s: write error: %s", dst, strerror(errno));
if (!status && adjust_shared_perm(dst))
return -1;
diff --git a/builtin-rerere.c b/builtin-rerere.c
index f6409b93c19aff7f8d820e52e39f45d717e31996..29fb075d29d2deb849e51578e2818d44dbb2a0d5 100644 (file)
--- a/builtin-rerere.c
+++ b/builtin-rerere.c
write_in_full(out_fd, path, length) != length)
die("unable to write rerere record");
}
- close(out_fd);
+ if (close(out_fd) != 0)
+ die("unable to write rerere record");
return commit_lock_file(&write_lock);
}
diff --git a/index-pack.c b/index-pack.c
index 82c8da3683bbda15a5f7476d93c14737617d3e49..8403c36b63c041fe0c81276391a0bbea906e833d 100644 (file)
--- a/index-pack.c
+++ b/index-pack.c
write_or_die(keep_fd, keep_msg, keep_msg_len);
write_or_die(keep_fd, "\n", 1);
}
- close(keep_fd);
+ if (close(keep_fd) != 0)
+ die("cannot write keep file");
report = "keep";
}
}
index 67ac97c713d071790f2d627f4c0435af23430fb8..4dc7e8b47659b75cc0dcf334f1bf33798b2e5157 100644 (file)
--- a/refs.c
+++ b/refs.c
len += sprintf(logrec + len - 1, "\t%.*s\n", msglen, msg) - 1;
written = len <= maxlen ? write_in_full(logfd, logrec, len) : -1;
free(logrec);
- close(logfd);
- if (written != len)
+ if (close(logfd) != 0 || written != len)
return error("Unable to append to %s", log_file);
return 0;
}
goto error_free_return;
}
written = write_in_full(fd, ref, len);
- close(fd);
- if (written != len) {
+ if (close(fd) != 0 || written != len) {
error("Unable to write to %s", lockpath);
goto error_unlink_return;
}