git/list[1] front-page[2] threads[3] people[4] search[5] about
 

bug: git-http-push fails to validate email address in LOCK request

From
RVRiku Voipio <riku.voipio@iki.fi>
Date
Apr 9, 2009, 11:19 UTC
Message-ID
<20090409111944.GA22297@kos.to>
Hi,

If for whatever case EMAIL env variable or gitconfig email= setting contains any special xml character <>%&, the lock request in push will fail, with a completly useless error message:

git push foo upstream-push:master
Error: cannot lock existing info/refs
error: failed to push some refs to 'https://git.foo.org/projects/foo'
using the undocumented GIT_CURL_VERBOSE=1 env variable:
-snip-
> LOCK /projects/foo/info/refs HTTP/1.1
Authorization: Basic nothisstringisnottheonefromthereallog
User-Agent: git/1.6.2.1
Host: git.foo.org
Accept: */*
Timeout: Second-600
Content-Type: text/xml
Content-Length: 225
Expect: 100-continue
< HTTP/1.1 100 Continue
* The requested URL returned error: 400
* Closing connection #0
Error: cannot lock existing info/refs
error: failed to push some refs to 'https://git.foo.org/projects/foo'
-snip-
Helpfully, the actual lock request is omitted.
After finding someone from git hoster to grep the logs:
[Tue Apr 07 14:13:24 2009] [error] [client 1.1.1.1] XML Parser
Error: XML parser error code: not well-formed (invalid token) (4)
from http-push.c, we see that the lock request is:
#define LOCK_REQUEST "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<D:lockinfo xmlns:D=\"DAV:\">\n<D:lockscope><D:exclusive/></D:lockscope>\n<D:locktype><D:write/></D:locktype>\n<D:owner>\n<D:href>mailto:%s</D:href>\n</D:owner>\n</D:lockinfo>"

So there is exactly one variable being set. Turns out the email address in .gitconfig was set to '<riku.voipio@iki.fi>'. Yes, a user error. This was copied from $EMAIL env variable, where using strings such as 'foo bar <foo.bar@corp.com>' have been a norm forever.

-- 
"rm -rf" only sounds scary if you don't have backups
Next: Mike Hommey
Message 1 of 4 in “bug: git-http-push fails to validate email address in LOCK request”
  1. Riku VoipioApr 9, 2009
  2. Mike HommeyApr 9, 2009
  3. Replace ",<,>,& with their respective XML entities in DAV requestsMike Hommey, Apr 9, 2009
  4. Replace ",<,>,& with their respective XML entities in DAV requestsMike Hommey, Apr 9, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.