You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2010/01/09 17:37:55 UTC
svn commit: r897493 - in /commons/sandbox/runtime/trunk/src/main/native:
os/win32/exec.c os/win32/main.c os/win32/posix.c shared/sbuf.c
Author: mturk
Date: Sat Jan 9 16:37:55 2010
New Revision: 897493
URL: http://svn.apache.org/viewvc?rev=897493&view=rev
Log:
Make sure sbuf is always double zero terminated
Modified:
commons/sandbox/runtime/trunk/src/main/native/os/win32/exec.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/posix.c
commons/sandbox/runtime/trunk/src/main/native/shared/sbuf.c
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/exec.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/exec.c?rev=897493&r1=897492&r2=897493&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/exec.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/exec.c Sat Jan 9 16:37:55 2010
@@ -267,7 +267,7 @@
if (ep->limit.timeout > 0)
endat = ACR_TimeNow() + ep->limit.timeout;
- if (ep->usertoken) {
+ if (IS_VALID_HANDLE(ep->usertoken)) {
/* XXX: for terminal services, handles cannot be
* inherited across sessions. This process must be created
* in our existing session. lpDesktop assignment appears
@@ -314,6 +314,7 @@
rc = ACR_GET_OS_ERROR();
goto cleanup;
}
+ ep->pid = pi.dwProcessId;
/* Close our side of the pipes
*/
@@ -346,7 +347,6 @@
ob[2].o.hEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
waith[waitn++] = ob[2].o.hEvent;
}
- ep->pid = pi.dwProcessId;
/* We have created a process with the suspended main thread.
* Resume the main process thread.
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c?rev=897493&r1=897492&r2=897493&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c Sat Jan 9 16:37:55 2010
@@ -369,6 +369,7 @@
return acr_SignalsInit();
}
while (sePrivileges[i]) {
+#if defined(DEBUG)
if ((rc = ACR_EnablePrivilege(sePrivileges[i])) != ERROR_SUCCESS) {
wchar_t buf[128];
_snwprintf(buf, sizeof(buf), L"Failed enabling %s",
@@ -376,11 +377,12 @@
/* Log that we couldn't set privilege */
acr_init_log_source(NULL);
do_syslog(ACR_LOG_WARN, buf, rc);
-#if defined(DEBUG)
fprintf(stderr, "[WARN] %S\n", buf);
fflush(stderr);
-#endif
}
+#else
+ ACR_EnablePrivilege(sePrivileges[i]);
+#endif
i++;
}
/* Do not display file not found messge boxes.
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/posix.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/posix.c?rev=897493&r1=897492&r2=897493&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/posix.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/posix.c Sat Jan 9 16:37:55 2010
@@ -114,6 +114,7 @@
}
}
}
+
if (psid == -1 && ctok == NULL) {
/* Fallback to a standard way
*/
@@ -141,6 +142,7 @@
} while (Process32NextW(snap, &e));
CloseHandle(snap);
}
+
if (psid != -1) {
HANDLE process = NULL;
if (psid)
@@ -155,12 +157,8 @@
}
if (process != NULL) {
if (!OpenProcessToken(process,
- TOKEN_ADJUST_PRIVILEGES |
TOKEN_QUERY |
- TOKEN_DUPLICATE |
- TOKEN_ASSIGN_PRIMARY |
- TOKEN_ADJUST_SESSIONID |
- TOKEN_READ|TOKEN_WRITE,
+ TOKEN_DUPLICATE,
&ctok)) {
/* Unable to open the process token
*/
@@ -179,9 +177,10 @@
}
}
}
+
if (IS_VALID_HANDLE(ctok)) {
if (DuplicateTokenEx(ctok,
- TOKEN_ASSIGN_PRIMARY | TOKEN_ALL_ACCESS,
+ MAXIMUM_ALLOWED,
0,
SecurityImpersonation,
TokenPrimary,
Modified: commons/sandbox/runtime/trunk/src/main/native/shared/sbuf.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/sbuf.c?rev=897493&r1=897492&r2=897493&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/sbuf.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/sbuf.c Sat Jan 9 16:37:55 2010
@@ -56,8 +56,8 @@
#define SBUF_ISDYNSTRUCT(s) ((s)->s_flags & ACR_SBUF_DYNSTRUCT)
#define SBUF_ISFINISHED(s) ((s)->s_flags & ACR_SBUF_FINISHED)
#define SBUF_HASOVERFLOWED(s) ((s)->s_flags & ACR_SBUF_OVERFLOWED || (s)->s_buf == NULL)
-#define SBUF_HASROOM(s) ((s)->s_len < ((s)->s_size - 1))
-#define SBUF_FREESPACE(s) ((s)->s_size - ((s)->s_len - 1))
+#define SBUF_HASROOM(s) ((s)->s_len < ((s)->s_size - 2))
+#define SBUF_FREESPACE(s) ((s)->s_size - ((s)->s_len - 2))
#define SBUF_CANEXTEND(s) ((s)->s_flags & ACR_SBUF_AUTOEXTEND)
/*
@@ -434,7 +434,8 @@
acr_sbuf_finish(acr_sbuf_t *s)
{
if (s->s_buf) {
- s->s_buf[s->s_len] = '\0';
+ s->s_buf[s->s_len++] = '\0';
+ s->s_buf[s->s_len] = '\0';
SBUF_CLRFLAG(s, ACR_SBUF_OVERFLOWED);
}
SBUF_SETFLAG(s, ACR_SBUF_FINISHED);
@@ -775,7 +776,8 @@
acr_wbuf_finish(acr_wbuf_t *s)
{
if (s->s_buf) {
- s->s_buf[s->s_len] = L'\0';
+ s->s_buf[s->s_len++] = L'\0';
+ s->s_buf[s->s_len] = L'\0';
SBUF_CLRFLAG(s, ACR_SBUF_OVERFLOWED);
}