Re: [PATCH] builtin/mv.c: fix possible segfault in add_slash()
- From
Jeff King <peff@peff.net>
- Date
- Sep 9, 2022, 02:21 UTC
- Message-ID
- <YxqjRphSqOHbBzGz@coredump.intra.peff.net>
- In-Reply-To
- <20220908230223.239970-1-shaoxuan.yuan02@gmail.com>
On Thu, Sep 08, 2022 at 04:02:23PM -0700, Shaoxuan Yuan wrote:
Show 5 quoted lines
> The purpose of add_slash() is adding a slash to the end of a string to > construct a directory path. And, because adding a slash to an empty > string is of no use here, and checking the string value without checking > it is non-empty leads to segfault, we should make sure the length of the > string is positive to solve both problems.
Thanks for picking this up. I had forgotten about it.
The patch looks obviously fine to me from the perspective of stopping the segfault. I'll take your "of no use here" as a given, not being familiar with the subtleties of mv's path handling. :) Assuming that's correct, then everything looks good to me.
-Peff