debian: apply security fixes from 2.24.1
[git/debian.git] / debian / patches / 0031-test-drop-caches-use-has_dos_drive_prefix.diff
blob6508152324af14370edc00e9a2ce041993ceac37
1 From 1b5536db226a0953c9f20ebe1e656e8335cdde7f Mon Sep 17 00:00:00 2001
2 From: Johannes Schindelin <johannes.schindelin@gmx.de>
3 Date: Wed, 4 Dec 2019 21:40:01 +0100
4 Subject: test-drop-caches: use `has_dos_drive_prefix()`
6 This is a companion patch to 'mingw: handle `subst`-ed "DOS drives"':
7 use the DOS drive prefix handling that is already provided by
8 `compat/mingw.c` (and which just learned to handle non-alphabetical
9 "drive letters").
11 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
12 (cherry picked from commit 68440496c77c6d3a606537c78ea4b62eb895a64a)
13 Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
14 ---
15 t/helper/test-drop-caches.c | 11 +++++++----
16 1 file changed, 7 insertions(+), 4 deletions(-)
18 diff --git a/t/helper/test-drop-caches.c b/t/helper/test-drop-caches.c
19 index f65e301f9d..7b4278462b 100644
20 --- a/t/helper/test-drop-caches.c
21 +++ b/t/helper/test-drop-caches.c
22 @@ -8,18 +8,21 @@ static int cmd_sync(void)
24 char Buffer[MAX_PATH];
25 DWORD dwRet;
26 - char szVolumeAccessPath[] = "\\\\.\\X:";
27 + char szVolumeAccessPath[] = "\\\\.\\XXXX:";
28 HANDLE hVolWrite;
29 - int success = 0;
30 + int success = 0, dos_drive_prefix;
32 dwRet = GetCurrentDirectory(MAX_PATH, Buffer);
33 if ((0 == dwRet) || (dwRet > MAX_PATH))
34 return error("Error getting current directory");
36 - if (!has_dos_drive_prefix(Buffer))
37 + dos_drive_prefix = has_dos_drive_prefix(Buffer);
38 + if (!dos_drive_prefix)
39 return error("'%s': invalid drive letter", Buffer);
41 - szVolumeAccessPath[4] = Buffer[0];
42 + memcpy(szVolumeAccessPath, Buffer, dos_drive_prefix);
43 + szVolumeAccessPath[dos_drive_prefix] = '\0';
45 hVolWrite = CreateFile(szVolumeAccessPath, GENERIC_READ | GENERIC_WRITE,
46 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
47 if (INVALID_HANDLE_VALUE == hVolWrite)
48 --
49 2.24.0.393.g34dc348eaf