Re: [RFC PATCHv2] repack: rewrite the shell script in C.
- From
Kyle J. McKay <mackyle@gmail.com>
- Date
- Aug 17, 2013, 19:18 UTC
- Message-ID
- <C3ED0A6F-4C7E-4433-966C-6EE00B9AAFEE@gmail.com>
- In-Reply-To
- <520F7BDE.9090902@web.de>
On Aug 17, 2013, at 06:34, René Scharfe wrote:
> On Aug 15, 2013, at 17:12, Stefan Beller wrote:
>> + if (sha_begin >= e->d_name && !strncmp(sha_begin, sha1, 40)) {
>> + char *fname;
>> + fname = xmalloc(strlen(path) + 1 + strlen(e->d_name));This needs another +1 because
>> + sprintf(fname, "%s/%s", path, e->d_name);
len(path) + len("/") + len(e->d_name) + len("\0")Show 7 quoted lines
> > mkpathdup.. > >> + unlink(fname); >> + /*TODO: free(fname); fails here sometimes, needs investigation*/ > > Strange. Perhaps valgrind can tell you what's wrong.
which is probably why it fails since the byte beyond the end of fname is being overwritten with a nul.