Re: [PATCH v1] handle lower case drive letters on Windows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Ben,

On Wed, 11 Jul 2018, Ben Peart wrote:

> Teach test-drop-caches to handle lower case drive letters on Windows.

Maybe mention that you can trigger this by using a lower case drive letter
in Powershell (CMD normalizes your path, Powershell does not).

> diff --git a/t/helper/test-drop-caches.c b/t/helper/test-drop-caches.c
> index d6bcfddf13..37047189c3 100644
> --- a/t/helper/test-drop-caches.c
> +++ b/t/helper/test-drop-caches.c
> @@ -16,7 +16,7 @@ static int cmd_sync(void)
>  	if ((0 == dwRet) || (dwRet > MAX_PATH))
>  		return error("Error getting current directory");
>  
> -	if ((Buffer[0] < 'A') || (Buffer[0] > 'Z'))
> +	if ((toupper(Buffer[0]) < 'A') || (toupper(Buffer[0]) > 'Z'))
>  		return error("Invalid drive letter '%c'", Buffer[0]);

This is a rather incomplete test, as it does not even test for the colon
after the drive letter.

But I guess the more common case where this code path triggers the error
is when your current directory is a UNC path to a file share (again, only
possible in Powershell, CMD does not let you do that unless you play
serious tricks).

So maybe a much better idea is to use our `has_dos_drive_prefix()`
function:

	if (!has_dos_drive_prefix(Buffer))
		return error("'%s': invalid drive letter", Buffer);

Ciao,
Johannes



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux