diff mbox series

mingw: check that the file attributes are valid

Message ID pull.1413.git.git.1671740551466.gitgitgadget@gmail.com (mailing list archive)
State Superseded
Headers show
Series mingw: check that the file attributes are valid | expand

Commit Message

Seija Kijin Dec. 22, 2022, 8:22 p.m. UTC
From: Seija Kijin <doremylover123@gmail.com>

If the attributes are invalid, return an error.

Signed-off-by: Seija Kijin <doremylover123@gmail.com>
---
    mingw: check that the file attributes are valid

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1413%2FAtariDreams%2Fset-hidden-flag-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1413/AtariDreams/set-hidden-flag-v1
Pull-Request: https://github.com/git/git/pull/1413

 compat/mingw.c | 5 +++++
 1 file changed, 5 insertions(+)


base-commit: 7c2ef319c52c4997256f5807564523dfd4acdfc7
diff mbox series

Patch

diff --git a/compat/mingw.c b/compat/mingw.c
index d614f156df1..71a039cdd7c 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -435,6 +435,11 @@  static inline int needs_hiding(const char *path)
 static int set_hidden_flag(const wchar_t *path, int set)
 {
 	DWORD original = GetFileAttributesW(path), modified;
+	if (original == INVALID_FILE_ATTRIBUTES) {
+		errno = err_win_to_posix(GetLastError());
+		return -1;
+	}
+
 	if (set)
 		modified = original | FILE_ATTRIBUTE_HIDDEN;
 	else