summaryrefslogtreecommitdiff
path: root/config.mak.in
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2014-09-13 20:19:20 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-09-15 18:38:13 (GMT)
commitd38379ece9216735ecc0ffd76c4c4e3da217daec (patch)
treed606187cb067344423ea4e08f7226948d4ead59f /config.mak.in
parent1cc2c772dd4dc5f9396a229e2727ca28ef25c33b (diff)
downloadgit-d38379ece9216735ecc0ffd76c4c4e3da217daec.zip
git-d38379ece9216735ecc0ffd76c4c4e3da217daec.tar.gz
git-d38379ece9216735ecc0ffd76c4c4e3da217daec.tar.bz2
make update-server-info more robust
Since "git update-server-info" may be called automatically as part of a push or a "gc --auto", we should be robust against two processes trying to update it simultaneously. However, we currently use a fixed tempfile, which means that two simultaneous writers may step on each other's toes and end up renaming junk into place. Let's instead switch to using a unique tempfile via mkstemp. We do not want to use a lockfile here, because it's OK for two writers to simultaneously update (one will "win" the rename race, but that's OK; they should be writing the same information). While we're there, let's clean up a few other things: 1. Detect write errors. Report them and abort the update if any are found. 2. Free path memory rather than leaking it (and clean up the tempfile when necessary). 3. Use the pathdup functions consistently rather than static buffers or manually calculated lengths. This last one fixes a potential overflow of "infofile" in update_info_packs (e.g., by putting large junk into $GIT_OBJECT_DIRECTORY). However, this overflow was probably not an interesting attack vector for two reasons: a. The attacker would need to control the environment to do this, in which case it was already game-over. b. During its setup phase, git checks that the directory actually exists, which means it is probably shorter than PATH_MAX anyway. Because both update_info_refs and update_info_packs share these same failings (and largely duplicate each other), this patch factors out the improved error-checking version into a helper function. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.mak.in')
0 files changed, 0 insertions, 0 deletions