From 19d71c6c9e5e99d96b01fd545072080ac11f8b31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Mon, 23 Jun 2014 10:53:23 +0200 Subject: [PATCH] Fixed apparent const violation in secaudit.c for Windows (cosmetic) The prototype for SetFileSecurityW() does not exhibit a const attribute for the second attribute, thus triggering a compiler warning. This warning can be silenced by copying the argument. --- src/secaudit.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/secaudit.c b/src/secaudit.c index dfd198c2..8ffb2a91 100644 --- a/src/secaudit.c +++ b/src/secaudit.c @@ -207,9 +207,11 @@ * Sep 2013, version 1.4.1 * - silenced an aliasing warning by gcc >= 4.8 * + * May 2014, version 1.4.2 * - decoded GENERIC_ALL permissions * - decoded more "well-known" and generic SIDs * - showed Windows ownership in verbose situations + * - fixed apparent const violations */ /* @@ -233,7 +235,7 @@ * General parameters which may have to be adapted to needs */ -#define AUDT_VERSION "1.4.1" +#define AUDT_VERSION "1.4.2" #define GET_FILE_SECURITY "ntfs_get_file_security" #define SET_FILE_SECURITY "ntfs_set_file_security" @@ -2397,7 +2399,7 @@ int local_build_mapping(struct MAPPING *mapping[], const char *usermap_path) #ifdef WIN32 /* TODO : check whether the device can store acls */ strcpy(mapfile,"x:\\" MAPDIR "\\" MAPFILE); - if (((le16*)usermap_path)[1] == ':') + if (((const le16*)usermap_path)[1] == ':') mapfile[0] = usermap_path[0]; else { GetModuleFileName(NULL, currpath, 261); @@ -2745,8 +2747,9 @@ BOOL applyattr(const char *fullname, const char *attr, } } } + /* const missing from stupid prototype */ bad = !SetFileSecurityW((LPCWSTR)fullname, - selection, (char*)curattr); + selection, (PSECURITY_DESCRIPTOR)(LONG_PTR)curattr); if (bad) switch (GetLastError()) { case 1307 : @@ -2755,9 +2758,12 @@ BOOL applyattr(const char *fullname, const char *attr, printname(stdout,fullname); printf(", retrying with no owner or SACL setting\n"); warnings++; + /* const missing from stupid prototype */ bad = !SetFileSecurityW((LPCWSTR)fullname, selection & ~OWNER_SECURITY_INFORMATION - & ~SACL_SECURITY_INFORMATION, (char*)curattr); + & ~SACL_SECURITY_INFORMATION, + (PSECURITY_DESCRIPTOR) + (LONG_PTR)curattr); break; default : break;