From: "H. Peter Anvin" <hpa@zytor.com>
To: Petr Baudis <pasky@suse.cz>
Cc: Junio C Hamano <junkio@cox.net>,
Dmitry Torokhov <dtor_core@ameritech.net>,
git@vger.kernel.org
Subject: Re: [PATCH] Fix git-init-db creating crap directories (zeroth try)
Date: Mon, 19 Sep 2005 17:42:47 -0700 [thread overview]
Message-ID: <432F5B07.2060803@zytor.com> (raw)
In-Reply-To: <20050920001949.GL18320@pasky.or.cz>
Petr Baudis wrote:
>>>
>>>- memcpy(path, git_dir, len);
>>>+ memcpy(path, git_dir, len-1);
>>>+ path[len] = 0;
>>> copy_templates_1(path, len,
>>
>>Wrong! You're not initializing path[len-1]!
>
>
> Oops, sorry. That's what you get when you want to make things marginally
> better. ;-) We indeed want to pass copy_templates_1() the trailing slash
> as well.
>
> Let's just settle with the original patch then.
>
But if len is the index of the '/', then you're not.
Think about it: the memcpy(path, git_dir, len) copies bytes 0..len-1.
Thus you need to use path[len] = 0 to terminate.
If you want to copy len-1 characters, then you need to use path[len-1] = 0.
-hpa
next prev parent reply other threads:[~2005-09-20 0:43 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-18 2:41 Garbage in .git directories??? Dmitry Torokhov
2005-09-18 17:10 ` Linus Torvalds
2005-09-18 17:54 ` Dmitry Torokhov
2005-09-19 4:33 ` Dmitry Torokhov
2005-09-19 5:21 ` Junio C Hamano
2005-09-19 14:51 ` Linus Torvalds
2005-09-19 15:00 ` Dmitry Torokhov
2005-09-20 0:09 ` Dmitry Torokhov
2005-09-20 0:45 ` Linus Torvalds
2005-09-20 3:37 ` Dmitry Torokhov
2005-09-19 19:10 ` H. Peter Anvin
2005-09-19 19:44 ` Petr Baudis
2005-09-19 23:16 ` H. Peter Anvin
2005-09-19 23:40 ` Petr Baudis
2005-09-19 23:58 ` H. Peter Anvin
2005-09-20 0:07 ` [PATCH] Fix git-init-db creating crap directories Petr Baudis
2005-09-20 0:09 ` H. Peter Anvin
2005-09-20 0:19 ` [PATCH] Fix git-init-db creating crap directories (zeroth try) Petr Baudis
2005-09-20 0:42 ` H. Peter Anvin [this message]
2005-09-20 1:51 ` Petr Baudis
2005-09-20 2:04 ` Junio C Hamano
2005-09-20 3:27 ` H. Peter Anvin
2005-09-19 21:58 ` Garbage in .git directories??? Horst von Brand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=432F5B07.2060803@zytor.com \
--to=hpa@zytor.com \
--cc=dtor_core@ameritech.net \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
--cc=pasky@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).