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

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

 



From: Seija Kijin <doremylover123@xxxxxxxxx>

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

Signed-off-by: Seija Kijin <doremylover123@xxxxxxxxx>
---
    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@xxxxxxxxx>
      
       ## 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(+)

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



[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