]> wimlib.net Git - wimlib/commitdiff
wimlib_vmsg(): Use correct error string buffer length
authorEric Biggers <ebiggers3@gmail.com>
Mon, 30 Dec 2013 08:39:40 +0000 (02:39 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Mon, 30 Dec 2013 08:42:30 +0000 (02:42 -0600)
src/util.c
src/win32_apply.c

index b2e59e40417c3a4a555770a0d6d462f632466e6a..2d151478164f247bca678f6583d7ae71a86550fa 100644 (file)
@@ -162,9 +162,9 @@ wimlib_vmsg(const tchar *tag, const tchar *format,
                tfputs(tag, stderr);
                wimlib_vfprintf(stderr, format, va);
                if (perror && errno_save != 0) {
-                       tchar buf[50];
+                       tchar buf[64];
                        int res;
-                       res = tstrerror_r(errno_save, buf, sizeof(buf));
+                       res = tstrerror_r(errno_save, buf, ARRAY_LEN(buf));
                        if (res) {
                                tsprintf(buf,
                                         T("unknown error (errno=%d)"),
index 6ac9e4090ec53bac1bf7585327652e1f433ab39f..b7646651efd5d08040dda18cad4d0e4ed0064e1d 100644 (file)
@@ -540,8 +540,9 @@ win32_set_security_descriptor(const wchar_t *path, const u8 *desc,
        if (func_NtSetSecurityObject) {
                h = win32_open_existing_file(path, MAXIMUM_ALLOWED);
                if (h == INVALID_HANDLE_VALUE) {
-                       ERROR_WITH_ERRNO("Can't open %ls (%u)", path, GetLastError());
-                       goto error;
+                       set_errno_from_GetLastError();
+                       ERROR_WITH_ERRNO("Can't open %ls", path);
+                       return WIMLIB_ERR_SET_SECURITY;
                }
        }
 #endif
@@ -549,8 +550,10 @@ win32_set_security_descriptor(const wchar_t *path, const u8 *desc,
        for (;;) {
                err = do_win32_set_security_descriptor(h, path, info,
                                                       (PSECURITY_DESCRIPTOR)desc);
-               if (err == ERROR_SUCCESS)
+               if (err == ERROR_SUCCESS) {
+                       ret = 0;
                        break;
+               }
                if ((err == ERROR_PRIVILEGE_NOT_HELD ||
                     err == ERROR_ACCESS_DENIED) &&
                    !(ctx->extract_flags & WIMLIB_EXTRACT_FLAG_STRICT_ACLS))
@@ -570,23 +573,18 @@ win32_set_security_descriptor(const wchar_t *path, const u8 *desc,
                        }
                        ctx->partial_security_descriptors--;
                        ctx->no_security_descriptors++;
+                       ret = 0;
                        break;
                }
-               SetLastError(err);
-               goto error;
+               set_errno_from_win32_error(err);
+               ret = WIMLIB_ERR_SET_SECURITY;
+               break;
        }
-       ret = 0;
-out_close:
 #ifdef WITH_NTDLL
-       if (func_NtSetSecurityObject && h != INVALID_HANDLE_VALUE)
+       if (func_NtSetSecurityObject)
                CloseHandle(h);
 #endif
        return ret;
-
-error:
-       set_errno_from_GetLastError();
-       ret = WIMLIB_ERR_SET_SECURITY;
-       goto out_close;
 }
 
 static int