Re: [PATCH v3 2/3] relative_path should honor DOS and UNC paths
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 18, 2013, 16:00 UTC
- Message-ID
- <xmqq4n9iw24q.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <CANYiYbF1XwKbD13AMZhE1c4hGMqVzpH9hZ-J8Gk-8AVFUCnn0g@mail.gmail.com>
Jiang Xin <worldhello.net@gmail.com> writes:
Show 9 quoted lines
> 2013/9/18 Junio C Hamano <gitster@pobox.com>: >>> + if (!is_dir_sep(*path) || !is_dir_sep(*(path+1)) || is_dir_sep(*(path+2))) >>> + return 0; >> If path[1] == '\0', it would be !is_dir_sep() and we end up >> inspecting past the end of the string? > > The funciton "is_unc_path" will return false (0), if path is > "", "/", "//", "///three/slashes/", or "/usr/local". > So the problem is ?
If path[1] == '\0' (e.g. path="/"), !is_dir_sep(path[1]) is true, not false (as I misread earlier), so we hit an early return and will not peek path[2]. So no problem. Sorry for the noise.
But I agree with J6t and Torsten in near-by thread that the simpler one that does not worry about // should be done as a separate patch and //, if we decide to do it, should build on top.
Thanks.