From: Junio C Hamano <gitster@pobox.com>
To: Alex Riesen <raa.lkml@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH] Handle the errors from chdir in set_work_tree
Date: Thu, 02 Aug 2007 15:18:47 -0700 [thread overview]
Message-ID: <7v4pjhtwag.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <20070802221518.GC2829@steel.home> (Alex Riesen's message of "Fri, 3 Aug 2007 00:15:18 +0200")
Alex Riesen <raa.lkml@gmail.com> writes:
> Junio C Hamano, Thu, Aug 02, 2007 23:58:41 +0200:
>> "Alex Riesen" <raa.lkml@gmail.com> writes:
>> > + if (chdir(dir))
>> > + rel = NULL;
> ...
>>
>> Shouldn't it die() instead, though?
>
> Dunno. Don't like dying.
I do not understand your reasoning. Why is it better to use
mysteriously truncated path, which may result in doing something
the user did not ask you to, rather than saying "No, my
temporary buffer is not equipped to handle such an insanely long
pathname"?
>> Consolidating two of your patches, would this be Ok?
>
> Yes, but you may consider replacing strncpy with strlcpy:
>
>> + memcpy(dir_buffer, dir, len - suffix_len);
>> + dir_buffer[len - suffix_len] = '\0';
>
> strlcpy(dir_buffer, dir, len - suffix_len + 1);
Does that buy us that much? Before going to that codepath, we
have made sure the result fits, haven't we?
prev parent reply other threads:[~2007-08-02 22:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-02 15:27 [PATCH] Handle the errors from chdir in set_work_tree Alex Riesen
2007-08-02 15:40 ` Johannes Schindelin
2007-08-02 21:58 ` Junio C Hamano
2007-08-02 22:07 ` Johannes Schindelin
2007-08-02 22:15 ` Alex Riesen
2007-08-02 22:18 ` Junio C Hamano [this message]
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=7v4pjhtwag.fsf@assigned-by-dhcp.cox.net \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=raa.lkml@gmail.com \
/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