diff -r 8e13cc0825f1 -r 40528ad1b1e8 mercurial/manifest.c --- a/mercurial/manifest.c Wed Mar 11 17:53:50 2015 -0700 +++ b/mercurial/manifest.c Thu Mar 12 09:06:45 2015 -0700 @@ -466,7 +466,10 @@ } memcpy(dest, path, plen + 1); for (i = 0; i < 20; i++) { - sprintf(dest + plen + 1 + (i * 2), "%02hhx", hash[i]); + /* Cast to unsigned, so it will not get sign-extended when promoted + * to int (as is done when passing to a variadic function) + */ + sprintf(dest + plen + 1 + (i * 2), "%02x", (unsigned char)hash[i]); } memcpy(dest + plen + 41, flags, flen); dest[plen + 41 + flen] = '\n';