threads / patch / 58995

patchmingw: check that the file attributes are valid

Subject: [PATCH] mingw: check that the file attributes are valid

## tl;dr

4 messages between Dec 22, 2022 and Dec 18, 2024. Diffs are folded; open one to read it.

replies: 3people: 2as markdown or json

Rose via GitGitGadget· Dec 22, 2022, 20:22 UTC · lore
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(+)
Show changes to compat/mingw.c +5 −0
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

base-commit: 7c2ef319c52c4997256f5807564523dfd4acdfc7
-- 
gitgitgadget
Rose via GitGitGadget· Jan 8, 2023, 14:46 UTC · re: Rose via GitGitGadget · lore

[PATCH v2] mingw: check that the file attributes are valid

From: Seija Kijin <doremylover123@gmail.com>

If the attributes are invalid, return -1 to indicate 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-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1413/AtariDreams/set-hidden-flag-v2
Pull-Request: https://github.com/git/git/pull/1413
Range-diff vs v1:
 1:  d2992745f3f ! 1:  f1cc7d9a98b mingw: check that the file attributes are valid
     @@ Metadata
       ## Commit message ##
          mingw: check that the file attributes are valid
      
     -    If the attributes are invalid, return an error.
     +    If the attributes are invalid, return -1
     +    to indicate an error.
      
          Signed-off-by: Seija Kijin <doremylover123@gmail.com>
      
 compat/mingw.c | 5 +++++
 1 file changed, 5 insertions(+)
Show changes to compat/mingw.c +5 −0
diff --git a/compat/mingw.c b/compat/mingw.c
index af397e68a1d..01bafa01e92 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

base-commit: a38d39a4c50d1275833aba54c4dbdfce9e2e9ca1
-- 
gitgitgadget
Rose via GitGitGadget· Jan 8, 2023, 14:49 UTC · re: Rose via GitGitGadget · lore

[PATCH v3] mingw: check that the file attributes are valid before modifying them

From: Seija Kijin <doremylover123@gmail.com>

If the attributes are invalid, return -1 to indicate an error.

Signed-off-by: Seija Kijin <doremylover123@gmail.com>
---
    mingw: check that the file attributes are valid before modifying them
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1413%2FAtariDreams%2Fset-hidden-flag-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1413/AtariDreams/set-hidden-flag-v3
Pull-Request: https://github.com/git/git/pull/1413
Range-diff vs v2:
 1:  f1cc7d9a98b ! 1:  0cbe8bce617 mingw: check that the file attributes are valid
     @@ Metadata
      Author: Seija Kijin <doremylover123@gmail.com>
      
       ## Commit message ##
     -    mingw: check that the file attributes are valid
     +    mingw: check that the file attributes are valid before modifying them
      
          If the attributes are invalid, return -1
          to indicate an error.
 compat/mingw.c | 5 +++++
 1 file changed, 5 insertions(+)
Show changes to compat/mingw.c +5 −0
diff --git a/compat/mingw.c b/compat/mingw.c
index af397e68a1d..01bafa01e92 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

base-commit: a38d39a4c50d1275833aba54c4dbdfce9e2e9ca1
-- 
gitgitgadget
AreaZR via GitGitGadget· Dec 18, 2024, 00:37 UTC · re: Rose via GitGitGadget · lore

[PATCH v4] mingw: check that the file attributes are valid before modifying them

From: Seija Kijin <doremylover123@gmail.com>

If the attributes are invalid, return -1 to indicate an error.

Signed-off-by: Seija Kijin <doremylover123@gmail.com>
---
    mingw: check that the file attributes are valid before modifying them
    
    Thanks for taking the time to contribute to Git! Please be advised that
    the Git community does not use github.com for their contributions.
    Instead, we use a mailing list (git@vger.kernel.org) for code
    submissions, code reviews, and bug reports. Nevertheless, you can use
    GitGitGadget (https://gitgitgadget.github.io/) to conveniently send your
    Pull Requests commits to our mailing list.
    
    Please read the "guidelines for contributing" linked above!
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1413%2FAreaZR%2Fset-hidden-flag-v4
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1413/AreaZR/set-hidden-flag-v4
Pull-Request: https://github.com/git/git/pull/1413
Range-diff vs v3:
 1:  0cbe8bce617 = 1:  0fed7ade880 mingw: check that the file attributes are valid before modifying them
 compat/mingw.c | 5 +++++
 1 file changed, 5 insertions(+)
Show changes to compat/mingw.c +5 −0
diff --git a/compat/mingw.c b/compat/mingw.c
index 63f36c893bf..7f52a4362fe 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -446,6 +446,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

base-commit: 063bcebf0c917140ca0e705cbe0fdea127e90086
-- 
gitgitgadget

← back to recent threads