Web lists-archives.com

RE: [PATCH v3 1/2] use HOST_NAME_MAX to size buffers for gethostname(2)




> I had another look at this last night and cooked up the following patch.  Might
> have gone overboard with it..
> 
> -- >8 --
> Subject: [PATCH] gc: support arbitrary hostnames and pids in lock_repo_for_gc()
> 
> git gc writes its pid and hostname into a pidfile to prevent concurrent garbage
> collection.  Repositories may be shared between systems with different limits
> for host name length and different pid ranges.  Use a strbuf to store the file
> contents to allow for arbitrarily long hostnames and pids to be shown to the
> user on early abort.

This is pretty paranoid, but maybe the remote host has a longer pid_t than we 
do, so we should be using intmax_t when reading the pid, and only check its 
size  before passing it to kill?

(Personally, I think this whole patch is kind of overkill, but some folks probably
think the same about my original patches, so I'm happy to live and let live).