[ros-diffs] [weiden] 20854: improved error handling

weiden at svn.reactos.org weiden at svn.reactos.org
Sat Jan 14 17:19:10 CET 2006


improved error handling
Modified: trunk/reactos/subsys/system/cacls/cacls.c
Property changes on: trunk/reactos/subsys/system/cacls
___________________________________________________________________
Name: svn:ignore
   + *.o
*.a
*.d
*.exe
*.coff
*.sym
*.map
GNUmakefile
  _____  

Modified: trunk/reactos/subsys/system/cacls/cacls.c
--- trunk/reactos/subsys/system/cacls/cacls.c	2006-01-14 16:08:57 UTC
(rev 20853)
+++ trunk/reactos/subsys/system/cacls/cacls.c	2006-01-14 16:18:45 UTC
(rev 20854)
@@ -19,7 +19,6 @@

 
 #include <precomp.h>
 
-
 static GENERIC_MAPPING FileGenericMapping =
 {
     FILE_GENERIC_READ,
@@ -28,6 +27,7 @@
     FILE_ALL_ACCESS
 };
 
+
 static INT
 LengthOfStrResource(IN HINSTANCE hInst,
                     IN UINT uID)
@@ -173,7 +173,7 @@
     PSECURITY_DESCRIPTOR SecurityDescriptor;
     DWORD SDSize = 0;
     TCHAR FullFileName[MAX_PATH + 1];
-    BOOL Ret = FALSE;
+    BOOL Error = FALSE, Ret = FALSE;
 
     Indent = _tcslen(FilePath) + _tcslen(FileName);
     if (Indent++ > MAX_PATH - 1)
@@ -250,16 +250,13 @@
                         {
                             if (GetLastError() == ERROR_NONE_MAPPED)
                             {
-                                if (!ConvertSidToStringSid(Sid,
-                                                           &SidString))
-                                {
-                                    break;
-                                }
+                                goto BuildSidString;
                             }
                             else
                             {
                                 if (GetLastError() !=
ERROR_INSUFFICIENT_BUFFER)
                                 {
+                                    Error = TRUE;
                                     break;
                                 }
 
@@ -269,6 +266,7 @@
                                 if (Name == NULL)
                                 {
 
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+                                    Error = TRUE;
                                     break;
                                 }
 
@@ -285,10 +283,21 @@
                                     HeapFree(GetProcessHeap(),
                                              0,
                                              Name);
-                                    break;
+                                    Name = NULL;
+                                    goto BuildSidString;
                                 }
                             }
                         }
+                        else
+                        {
+BuildSidString:
+                            if (!ConvertSidToStringSid(Sid,
+                                                       &SidString))
+                            {
+                                Error = TRUE;
+                                break;
+                            }
+                        }
 
                         /* print the file name or space */
                         _tprintf(_T("%s "),
@@ -389,7 +398,8 @@
                                     DWORD Access;
                                     UINT uID;
                                 }
-                                AccessRights[] = {
+                                AccessRights[] =
+                                {
                                     {FILE_WRITE_ATTRIBUTES,
IDS_FILE_WRITE_ATTRIBUTES},
                                     {FILE_READ_ATTRIBUTES,
IDS_FILE_READ_ATTRIBUTES},
                                     {FILE_DELETE_CHILD,
IDS_FILE_DELETE_CHILD},
@@ -467,7 +477,8 @@
                         AceIndex++;
                     }
 
-                    Ret = TRUE;
+                    if (!Error)
+                        Ret = TRUE;
                 }
                 else
                 {
@@ -512,6 +523,7 @@
         TCHAR *FilePart = NULL;
         WIN32_FIND_DATA FindData;
         HANDLE hFind;
+        DWORD LastError;
         BOOL ContinueAccessDenied = FALSE;
 
         if (argc > 2)
@@ -553,11 +565,15 @@
                         if (!PrintFileDacl(FullPath,
                                            FindData.cFileName))
                         {
-                            if (GetLastError() == ERROR_ACCESS_DENIED
&&
-                                !ContinueAccessDenied)
+                            LastError = GetLastError();
+
+                            if (LastError == ERROR_ACCESS_DENIED &&
+                                ContinueAccessDenied)
                             {
+                                PrintErrorMessage(LastError);
+                            }
+                            else
                                 break;
-                            }
                         }
                         else
                             _tprintf(_T("\n"));
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.reactos.org/pipermail/ros-diffs/attachments/20060114/179ebe3c/attachment.html


More information about the Ros-diffs mailing list