Author: mturk Date: Fri Jan 15 10:38:48 2010 New Revision: 899585 URL: http://svn.apache.org/viewvc?rev=899585&view=rev Log: Use x_strdup only where double zero terminated strings are needed
Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h commons/sandbox/runtime/trunk/src/main/native/os/solaris/env.c commons/sandbox/runtime/trunk/src/main/native/os/unix/dir.c commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c commons/sandbox/runtime/trunk/src/main/native/os/unix/fsysio.c commons/sandbox/runtime/trunk/src/main/native/os/win32/exec.c commons/sandbox/runtime/trunk/src/main/native/os/win32/fsysio.c commons/sandbox/runtime/trunk/src/main/native/os/win32/mutex.c commons/sandbox/runtime/trunk/src/main/native/os/win32/pipe.c commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c commons/sandbox/runtime/trunk/src/main/native/os/win32/registry.c commons/sandbox/runtime/trunk/src/main/native/os/win32/sema.c commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c commons/sandbox/runtime/trunk/src/main/native/os/win32/subproc.c commons/sandbox/runtime/trunk/src/main/native/os/win32/subsys.c commons/sandbox/runtime/trunk/src/main/native/os/win32/temps.c commons/sandbox/runtime/trunk/src/main/native/os/win32/wusec.c commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c commons/sandbox/runtime/trunk/src/main/native/shared/args.c Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h?rev=899585&r1=899584&r2=899585&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h (original) +++ commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h Fri Jan 15 10:38:48 2010 @@ -896,7 +896,7 @@ #define IS_INVALID_HANDLE(h) (((h) == NULL || (h) == INVALID_HANDLE_VALUE)) #define IS_VALID_HANDLE(h) (((h) != NULL && (h) != INVALID_HANDLE_VALUE)) -#define INVALID_JNIENV ((void *)(ptrdiff_t)-1) +#define INVALID_JNIENV ((JNIEnv *)(ptrdiff_t)-1) #define INVALID_MEMORY_VALUE ((void *)(ptrdiff_t)-1) #define IS_INVALID_MEMORY(h) (((h) == NULL || (h) == INVALID_MEMORY_VALUE)) #define IS_VALID_MEMORY(h) (((h) != NULL && (h) != INVALID_MEMORY_VALUE)) Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h?rev=899585&r1=899584&r2=899585&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h (original) +++ commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h Fri Jan 15 10:38:48 2010 @@ -119,6 +119,27 @@ (O)->OffsetHigh = _li.HighPart; \ } else (void)0 +typedef struct OVERLAPPED_SBUFF { + OVERLAPPED o; + DWORD stat; + DWORD size; + char buff[ACR_SBUFF_SIZ]; +} OVERLAPPED_SBUFF; + +typedef struct OVERLAPPED_HBUFF { + OVERLAPPED o; + DWORD stat; + DWORD size; + char buff[ACR_HBUFF_SIZ]; +} OVERLAPPED_HBUFF; + +typedef struct OVERLAPPED_VBUFF { + OVERLAPPED o; + DWORD stat; + DWORD size; + char buff[]; +} OVERLAPPED_VBUFF; + /** * Local functions from path.c */ Modified: commons/sandbox/runtime/trunk/src/main/native/os/solaris/env.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/solaris/env.c?rev=899585&r1=899584&r2=899585&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/solaris/env.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/solaris/env.c Fri Jan 15 10:38:48 2010 @@ -24,7 +24,7 @@ ACR_DECLARE(char *) ACR_EnvGet(const char *var) { - return ACR_StrdupA(INVALID_HANDLE_VALUE, THROW_NMARK, getenv(var)); + return ACR_strdup(getenv(var)); } ACR_DECLARE(int) ACR_EnvHas(const char *var) Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/dir.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/dir.c?rev=899585&r1=899584&r2=899585&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/unix/dir.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/unix/dir.c Fri Jan 15 10:38:48 2010 @@ -248,10 +248,10 @@ WITH_ZCSTR(path) { WITH_ZCSTR(prefix) { - /* Provide INVALID_HANDLE_VALUE for JNIEnv + /* Provide INVALID_JNIENV for JNIEnv * so that in case of failure, exception doesn't get thrown */ - tmpd = ACR_TempDirMake(INVALID_HANDLE_VALUE, J2S(path), J2S(prefix)); + tmpd = ACR_TempDirMake(INVALID_JNIENV, J2S(path), J2S(prefix)); if (!tmpd) rc = ACR_GET_OS_ERROR(); } END_WITH_CSTR(prefix); @@ -275,7 +275,7 @@ UNREFERENCED_O; WITH_ZCSTR(paths) { - tmpd = ACR_TempPathGet(INVALID_HANDLE_VALUE, J2S(paths)); + tmpd = ACR_TempPathGet(INVALID_JNIENV, J2S(paths)); } END_WITH_CSTR(paths); if (tmpd) return ACR_NewPathObject(_E, ACR_PATH_ABS, tmpd); Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c?rev=899585&r1=899584&r2=899585&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c Fri Jan 15 10:38:48 2010 @@ -702,7 +702,7 @@ if (e) { x_free(e->currdir); if (path) { - if (!(e->currdir = x_strdup(path))) + if (!(e->currdir = ACR_strdup(path))) return ACR_ENOMEM; } return 0; Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c?rev=899585&r1=899584&r2=899585&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c Fri Jan 15 10:38:48 2010 @@ -470,10 +470,10 @@ WITH_ZCSTR(path) { WITH_ZCSTR(prefix) { - /* Provide INVALID_HANDLE_VALUE for JNIEnv + /* Provide INVALID_JNIENV for JNIEnv * so that in case of failure, exception doesn't get thrown */ - tmpd = ACR_TempDirMake(INVALID_HANDLE_VALUE, J2S(path), J2S(prefix)); + tmpd = ACR_TempDirMake(INVALID_JNIENV, J2S(path), J2S(prefix)); if (!tmpd) rc = ACR_GET_OS_ERROR(); } END_WITH_CSTR(prefix); @@ -496,7 +496,7 @@ UNREFERENCED_O; WITH_ZCSTR(paths) { - tmpd = ACR_TempPathGet(INVALID_HANDLE_VALUE, J2S(paths)); + tmpd = ACR_TempPathGet(INVALID_JNIENV, J2S(paths)); } END_WITH_CSTR(paths); if (tmpd) return ACR_NewPathObject(_E, ACR_PATH_ABS, tmpd); Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/fsysio.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/fsysio.c?rev=899585&r1=899584&r2=899585&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/unix/fsysio.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/unix/fsysio.c Fri Jan 15 10:38:48 2010 @@ -700,7 +700,7 @@ d->type = f->type; d->blocking = f->blocking; d->timeout = f->timeout; - d->name = x_strdup(f->name); + d->name = ACR_strdup(f->name); df = acr_ioh_open(d, ACR_DT_FILE, 0, file_cleanup); if (df < 0) { 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=899585&r1=899584&r2=899585&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 Fri Jan 15 10:38:48 2010 @@ -37,7 +37,6 @@ */ #define PROC_TIMEOUT_STEP 100 -#define PROC_BUFFER_SIZE 512 #define PIPE_STDINP_RDS 0 #define PIPE_STDINP_WRS 1 @@ -59,11 +58,11 @@ ep->flags = flags; if (flags & ACR_PROC_HAS_STDOUT) { - if ((rc = acr_sbuf_init(&ep->sout, NULL, PROC_BUFFER_SIZE))) + if ((rc = acr_sbuf_init(&ep->sout, NULL, ACR_SBUFF_SIZ))) goto cleanup; } if (flags & ACR_PROC_HAS_STDERR) { - if ((rc = acr_sbuf_init(&ep->serr, NULL, PROC_BUFFER_SIZE))) + if ((rc = acr_sbuf_init(&ep->serr, NULL, ACR_SBUFF_SIZ))) goto cleanup; } return ep; @@ -109,7 +108,7 @@ if (e) { x_free(e->currdir); if (path) { - if (!(e->currdir = x_wcsdup(path))) + if (!(e->currdir = ACR_wcsdup(path))) return ACR_ENOMEM; } return 0; @@ -142,12 +141,6 @@ return 0; } -typedef struct OVERLAPPED_BUFFER { - OVERLAPPED o; - DWORD stat; - char buff[PROC_BUFFER_SIZE]; -} OVERLAPPED_BUFFER; - static int do_exec(acr_exec_t *ep, const wchar_t *cmdline, const wchar_t **argv, wchar_t *const *envp) @@ -162,10 +155,10 @@ BOOL iostat; DWORD exitval; HANDLE pipes[6]; - HANDLE waith[3]; + HANDLE waithandle[3]; DWORD waitn = 0; DWORD dwTimeout = INFINITE; - OVERLAPPED_BUFFER ob[3]; + OVERLAPPED_SBUFF overlap[3]; DWORD dwCreationFlags = CREATE_UNICODE_ENVIRONMENT | CREATE_SUSPENDED; DWORD dwPipeFlags; const char *inpp = NULL; @@ -176,11 +169,11 @@ /* Before doing anything zero the stack so we * can safely go to cleanup. */ - ACR_MEMZERO(HANDLE, pipes, 6); - ACR_MEMZERO(HANDLE, waith, 3); - ACR_MEMZERO(OVERLAPPED_BUFFER, ob, 3); - ACR_MEMZERO(PROCESS_INFORMATION, &pi, 1); - ACR_MEMZERO(STARTUPINFOW, &si, 1); + ACR_MEMZERO(HANDLE, pipes, 6); + ACR_MEMZERO(HANDLE, waithandle, 3); + ACR_MEMZERO(OVERLAPPED_SBUFF, overlap, 3); + ACR_MEMZERO(PROCESS_INFORMATION, &pi, 1); + ACR_MEMZERO(STARTUPINFOW, &si, 1); si.cb = sizeof(si); ep->exitwhy = ACR_PARENT_ERROR; @@ -350,17 +343,17 @@ /* Setup wait handles */ if (IS_VALID_HANDLE(pipes[PIPE_STDOUT_RDS])) { - ob[0].o.hEvent = CreateEvent(NULL, TRUE, TRUE, NULL); - waith[waitn++] = ob[0].o.hEvent; + overlap[0].o.hEvent = CreateEvent(NULL, TRUE, TRUE, NULL); + waithandle[waitn++] = overlap[0].o.hEvent; } if (IS_VALID_HANDLE(pipes[PIPE_STDERR_RDS]) && (ep->flags & ACR_PROC_HAS_STDERR)) { - ob[1].o.hEvent = CreateEvent(NULL, TRUE, TRUE, NULL); - waith[waitn++] = ob[1].o.hEvent; + overlap[1].o.hEvent = CreateEvent(NULL, TRUE, TRUE, NULL); + waithandle[waitn++] = overlap[1].o.hEvent; } if (IS_VALID_HANDLE(pipes[PIPE_STDINP_WRS])) { - ob[2].o.hEvent = CreateEvent(NULL, TRUE, TRUE, NULL); - waith[waitn++] = ob[2].o.hEvent; + overlap[2].o.hEvent = CreateEvent(NULL, TRUE, TRUE, NULL); + waithandle[waitn++] = overlap[2].o.hEvent; } /* We have created a process with the suspended main thread. @@ -387,7 +380,7 @@ * because their events are set on signaled. This usualy means that * the first ReadFile/WriteFile will fail with ERROR_IO_PENDING. */ - ws = ACR_WaitForMultipleObjectOrSignal(waitn, waith, dwTimeout); + ws = ACR_WaitForMultipleObjectOrSignal(waitn, waithandle, dwTimeout); switch (ws) { case WAIT_ACRSIGNAL_0: /* Signal event is set. @@ -399,34 +392,34 @@ /* Signal on stdout stream */ if (IS_VALID_HANDLE(pipes[PIPE_STDOUT_RDS])) { - if (ob[0].stat == ERROR_IO_PENDING) { + if (overlap[0].stat == ERROR_IO_PENDING) { if (!GetOverlappedResult(pipes[PIPE_STDOUT_RDS], - &ob[0].o, + (LPOVERLAPPED)&overlap[0], &rd, FALSE)) { - ob[0].stat = GetLastError(); + overlap[0].stat = GetLastError(); } else { - ob[0].stat = 0; - rd = acr_sbuf_bcat(&ep->sout, ob[0].buff, rd); + overlap[0].stat = 0; + rd = acr_sbuf_bcat(&ep->sout, overlap[0].buff, rd); } rc = ACR_EINTR; break; } iostat = ReadFile(pipes[PIPE_STDOUT_RDS], - ob[0].buff, sizeof(ob[0].buff), - &rd, &ob[0].o); + overlap[0].buff, sizeof(overlap[0].buff), + &rd, (LPOVERLAPPED)&overlap[0]); if (iostat && rd != 0) { - ob[0].stat = 0; - rd = acr_sbuf_bcat(&ep->sout, ob[0].buff, rd); + overlap[0].stat = 0; + rd = acr_sbuf_bcat(&ep->sout, overlap[0].buff, rd); /* Issue another read */ - SetEvent(ob[0].o.hEvent); + SetEvent(overlap[0].o.hEvent); } else { - ob[0].stat = GetLastError(); - if (ob[0].stat != ERROR_IO_PENDING) { + overlap[0].stat = GetLastError(); + if (overlap[0].stat != ERROR_IO_PENDING) { SAFE_CLOSE_HANDLE(pipes[PIPE_STDOUT_RDS]); - ResetEvent(ob[0].o.hEvent); + ResetEvent(overlap[0].o.hEvent); } } } @@ -438,34 +431,34 @@ /* Signal on stderr stream */ if (IS_VALID_HANDLE(pipes[PIPE_STDERR_RDS])) { - if (ob[1].stat == ERROR_IO_PENDING) { + if (overlap[1].stat == ERROR_IO_PENDING) { if (!GetOverlappedResult(pipes[PIPE_STDERR_RDS], - &ob[1].o, + (LPOVERLAPPED)&overlap[1], &rd, FALSE)) { - ob[1].stat = GetLastError(); + overlap[1].stat = GetLastError(); } else { - ob[1].stat = 0; - rd = acr_sbuf_bcat(&ep->serr, ob[1].buff, rd); + overlap[1].stat = 0; + rd = acr_sbuf_bcat(&ep->serr, overlap[1].buff, rd); } rc = ACR_EINTR; break; } iostat = ReadFile(pipes[PIPE_STDERR_RDS], - ob[1].buff, sizeof(ob[1].buff), - &rd, &ob[1].o); + overlap[1].buff, sizeof(overlap[1].buff), + &rd, (LPOVERLAPPED)&overlap[1]); if (iostat && rd != 0) { - ob[1].stat = 0; - rd = acr_sbuf_bcat(&ep->serr, ob[1].buff, rd); + overlap[1].stat = 0; + rd = acr_sbuf_bcat(&ep->serr, overlap[1].buff, rd); /* Issue another read */ - SetEvent(ob[1].o.hEvent); + SetEvent(overlap[1].o.hEvent); } else { - ob[1].stat = GetLastError(); - if (ob[1].stat != ERROR_IO_PENDING) { + overlap[1].stat = GetLastError(); + if (overlap[1].stat != ERROR_IO_PENDING) { SAFE_CLOSE_HANDLE(pipes[PIPE_STDERR_RDS]); - ResetEvent(ob[1].o.hEvent); + ResetEvent(overlap[1].o.hEvent); } } } @@ -478,15 +471,15 @@ */ if (IS_VALID_HANDLE(pipes[PIPE_STDINP_WRS]) && ep->data.iov_len > 0) { - if (ob[2].stat == ERROR_IO_PENDING) { + if (overlap[2].stat == ERROR_IO_PENDING) { if (!GetOverlappedResult(pipes[PIPE_STDINP_WRS], - &ob[2].o, + (LPOVERLAPPED)&overlap[2], &wr, FALSE)) { - ob[2].stat = GetLastError(); + overlap[2].stat = GetLastError(); } else { - ob[2].stat = 0; + overlap[2].stat = 0; ep->data.iov_len -= wr; inpp += wr; } @@ -494,17 +487,18 @@ break; } iostat = WriteFile(pipes[PIPE_STDINP_WRS], inpp, - ep->data.iov_len, &wr, &ob[2].o); + ep->data.iov_len, &wr, + (LPOVERLAPPED)&overlap[2]); if (iostat && wr != 0) { ep->data.iov_len -= wr; inpp += wr; } else { - ob[2].stat = GetLastError(); - if (ob[2].stat != ERROR_IO_PENDING) { + overlap[2].stat = GetLastError(); + if (overlap[2].stat != ERROR_IO_PENDING) { FlushFileBuffers(pipes[PIPE_STDINP_WRS]); SAFE_CLOSE_HANDLE(pipes[PIPE_STDINP_WRS]); - ResetEvent(ob[1].o.hEvent); + ResetEvent(overlap[1].o.hEvent); } } } @@ -580,7 +574,7 @@ for (i = 0; i < 6; i++) SAFE_CLOSE_HANDLE(pipes[i]); for (i = 0; i < 3; i++) { - SAFE_CLOSE_HANDLE(ob[i].o.hEvent); + SAFE_CLOSE_HANDLE(overlap[i].o.hEvent); } x_free(args); x_free(envb); Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/fsysio.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/fsysio.c?rev=899585&r1=899584&r2=899585&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/win32/fsysio.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/fsysio.c Fri Jan 15 10:38:48 2010 @@ -194,14 +194,14 @@ sa.bInheritHandle = FALSE; if (prot == ACR_FPROT_OS_DEFAULT) { /* Allow access only to owner and Administrators Group */ - sa.lpSecurityDescriptor = ACR_StdSecurityDescriptor(INVALID_HANDLE_VALUE, + sa.lpSecurityDescriptor = ACR_StdSecurityDescriptor(INVALID_JNIENV, ACR_DT_FILE, ACR_FPROT_URWX | ACR_FPROT_GRWX); } else { /* Use provided protection flags */ - sa.lpSecurityDescriptor = ACR_StdSecurityDescriptor(INVALID_HANDLE_VALUE, + sa.lpSecurityDescriptor = ACR_StdSecurityDescriptor(INVALID_JNIENV, ACR_DT_FILE, prot); } @@ -729,7 +729,7 @@ d->type = f->type; d->blocking = f->blocking; d->timeout = f->timeout; - d->name = x_wcsdup(f->name); + d->name = ACR_wcsdup(f->name); df = acr_ioh_open(d, ACR_DT_FILE, 0, file_cleanup); if (df < 0) { Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/mutex.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/mutex.c?rev=899585&r1=899584&r2=899585&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/win32/mutex.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/mutex.c Fri Jan 15 10:38:48 2010 @@ -74,7 +74,7 @@ * with Modify access to Authenticated users */ sa.nLength = sizeof(SECURITY_ATTRIBUTES); - sa.lpSecurityDescriptor = ACR_StdSecurityDescriptor(INVALID_HANDLE_VALUE, + sa.lpSecurityDescriptor = ACR_StdSecurityDescriptor(INVALID_JNIENV, ACR_DT_MUTEX, ACR_FPROT_URWX | ACR_FPROT_GRWX | Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/pipe.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/pipe.c?rev=899585&r1=899584&r2=899585&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/win32/pipe.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/pipe.c Fri Jan 15 10:38:48 2010 @@ -285,7 +285,7 @@ } if (pname) { /* Return the unique pipe name */ - *pname = x_wcsdup(name); + *pname = ACR_wcsdup(name); } return 0; } Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c?rev=899585&r1=899584&r2=899585&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c Fri Jan 15 10:38:48 2010 @@ -72,12 +72,12 @@ * Create standard security descriptors */ /* All file access to Admins */ - ACR_GetSecurityDescriptor(INVALID_HANDLE_VALUE, + ACR_GetSecurityDescriptor(INVALID_JNIENV, GENERIC_ALL | FILE_ALL_ACCESS, GENERIC_ALL | FILE_ALL_ACCESS, 0); /* RWX file access to Authenticated users */ - ACR_GetSecurityDescriptor(INVALID_HANDLE_VALUE, + ACR_GetSecurityDescriptor(INVALID_JNIENV, GENERIC_ALL | FILE_ALL_ACCESS, GENERIC_ALL | FILE_ALL_ACCESS, GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | @@ -88,7 +88,7 @@ if (!SHELL_PATH) { /* Hope the PATH is set correctly */ - SHELL_PATH = x_wcsdup(L"CMD.EXE"); + SHELL_PATH = ACR_wcsdup(L"CMD.EXE"); } return acr_ioh_init(ios); } Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/registry.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/registry.c?rev=899585&r1=899584&r2=899585&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/win32/registry.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/registry.c Fri Jan 15 10:38:48 2010 @@ -149,7 +149,7 @@ ACR_SET_OS_ERROR(ACR_EINVAL); return NULL; } - k->name = x_wcsdup(p + 1); + k->name = ACR_wcsdup(p + 1); k->sam = wcs_flags(sam); if ((i = RegOpenKeyExW(r, k->name, 0, @@ -236,7 +236,7 @@ if (!(p = wcschr(name, L'\\'))) { return ACR_EINVAL; } - k.name = x_wcsdup(p + 1); + k.name = ACR_wcsdup(p + 1); k.sam = wcs_flags(sam); if ((s = wcschr(k.name, L'\\'))) { @@ -317,7 +317,7 @@ ACR_SET_OS_ERROR(ACR_EINVAL); return NULL; } - k->name = x_wcsdup(p + 1); + k->name = ACR_wcsdup(p + 1); k->sam = wcs_flags(sam); if ((i = RegCreateKeyExW(r, k->name, 0, NULL, 0, @@ -399,11 +399,11 @@ break; case REG_DWORD: memcpy(&rt, bb, 4); - value = x_strdup(itoa(rt, tb, 10)); + value = ACR_strdup(itoa(rt, tb, 10)); break; case REG_QWORD: memcpy(&qw, bb, 8); - value = x_strdup(_i64toa(qw, tb, 10)); + value = ACR_strdup(_i64toa(qw, tb, 10)); break; case REG_BINARY: value = x_malloc(rl * 4 + 1); @@ -490,11 +490,11 @@ break; case REG_DWORD: memcpy(&rt, bb, 4); - value = x_wcsdup(_itow(rt, tb, 10)); + value = ACR_wcsdup(_itow(rt, tb, 10)); break; case REG_QWORD: memcpy(&qw, bb, 8); - value = x_wcsdup(_i64tow(qw, tb, 10)); + value = ACR_wcsdup(_i64tow(qw, tb, 10)); break; case REG_BINARY: value = s_malloc(wchar_t, rl * 4 + 1); @@ -735,7 +735,7 @@ if (!(p = wcschr(name, '\\'))) { return ACR_EINVAL; } - k.name = x_wcsdup(p + 1); + k.name = ACR_wcsdup(p + 1); k.sam = KEY_READ; k.key = 0; if ((s = wcsrchr(k.name, L'\\'))) { @@ -791,7 +791,7 @@ if (wcscmp(basename, fname) == 0 && wcscasecmp(ext, L".EXE") == 0) { /* XXX: What is first checked? SearchPath or App Paths? */ - exn = ACR_StrvcatW(INVALID_HANDLE_VALUE, THROW_NMARK, + exn = ACR_StrvcatW(THROW_NEVER, NULL, L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\", basename, @@ -836,7 +836,7 @@ /* Step 2: * Get the Shell open command */ - exn = ACR_StrvcatW(INVALID_HANDLE_VALUE, THROW_NMARK, + exn = ACR_StrvcatW(THROW_NEVER, exn, L"\\SHELL\\OPEN\\COMMAND", NULL); if (exn == NULL) return ACR_ENOMEM; @@ -859,7 +859,7 @@ if (wcscasecmp(ext, L".BAT") == 0 || wcscasecmp(ext, L".CMD") == 0) { /* Special case for batch files */ - wchar_t *sh = ACR_StrvcatW(INVALID_HANDLE_VALUE, THROW_NMARK, + wchar_t *sh = ACR_StrvcatW(THROW_NEVER, NULL, SHELL_PATH, L" /D /C ", Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/sema.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/sema.c?rev=899585&r1=899584&r2=899585&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/win32/sema.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/sema.c Fri Jan 15 10:38:48 2010 @@ -82,7 +82,7 @@ * with Modify access to Authenticated users */ sa.nLength = sizeof(SECURITY_ATTRIBUTES); - sa.lpSecurityDescriptor = ACR_StdSecurityDescriptor(INVALID_HANDLE_VALUE, + sa.lpSecurityDescriptor = ACR_StdSecurityDescriptor(INVALID_JNIENV, ACR_DT_SEMAPHORE, ACR_FPROT_URWX | ACR_FPROT_GRWX | Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c?rev=899585&r1=899584&r2=899585&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c Fri Jan 15 10:38:48 2010 @@ -171,7 +171,7 @@ /* Name-based shared memory */ else { sa.nLength = sizeof(SECURITY_ATTRIBUTES); - sa.lpSecurityDescriptor = ACR_StdSecurityDescriptor(INVALID_HANDLE_VALUE, + sa.lpSecurityDescriptor = ACR_StdSecurityDescriptor(INVALID_JNIENV, ACR_DT_FILE, ACR_FPROT_URWX | ACR_FPROT_GRWX); Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/subproc.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/subproc.c?rev=899585&r1=899584&r2=899585&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/win32/subproc.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/subproc.c Fri Jan 15 10:38:48 2010 @@ -59,13 +59,6 @@ */ #define PROC_TIMEOUT_STEP 100 -#define PROC_BUFFER_SIZE 512 -typedef struct OVERLAPPED_BUFFER { - OVERLAPPED o; - DWORD stat; - char buff[PROC_BUFFER_SIZE]; -} OVERLAPPED_BUFFER; - #define PIPE_STDINP_RPC 0 #define PIPE_STDOUT_RPC 1 @@ -124,8 +117,8 @@ HANDLE waithandle[6]; DWORD waitn = 0; DWORD dwTimeout = INFINITE; - OVERLAPPED_BUFFER overlap[3]; - char pstdinb[PROC_BUFFER_SIZE]; + OVERLAPPED_SBUFF overlap[3]; + char pstdinb[ACR_SBUFF_SIZ]; DWORD dwCreationFlags = CREATE_UNICODE_ENVIRONMENT | CREATE_SUSPENDED | DETACHED_PROCESS; DWORD dwPipeFlags; acr_exec_t child; @@ -136,7 +129,7 @@ ACR_MEMZERO(acr_exec_t, &child, 1); ACR_MEMZERO(HANDLE, ppipe, 3); ACR_MEMZERO(HANDLE, pipes, 6); - ACR_MEMZERO(OVERLAPPED_BUFFER, overlap, 3); + ACR_MEMZERO(OVERLAPPED_SBUFF, overlap, 3); child.pid = -1; si.cb = sizeof(si); @@ -144,7 +137,7 @@ ACR_DEBUG((THROW_FMARK, "Failed to initialize the ACR error=%d\n", rc)); goto cleanup; } - if ((rc = ACR_PlatformInitialize(INVALID_HANDLE_VALUE, 0))) { + if ((rc = ACR_PlatformInitialize(INVALID_JNIENV, 0))) { ACR_DEBUG((THROW_FMARK, "Failed to initialize the ACR platform error=%d\n", rc)); goto cleanup; } @@ -488,7 +481,7 @@ if (IS_VALID_HANDLE(pipes[PIPE_STDOUT_RDS])) { if (overlap[0].stat == ERROR_IO_PENDING) { if (!GetOverlappedResult(pipes[PIPE_STDOUT_RDS], - &overlap[0].o, + (LPOVERLAPPED)&overlap[0], &rd, FALSE)) { overlap[0].stat = GetLastError(); @@ -501,8 +494,8 @@ break; } iostat = ReadFile(pipes[PIPE_STDOUT_RDS], - overlap[0].buff, PROC_BUFFER_SIZE, - &rd, &overlap[0].o); + overlap[0].buff, ACR_SBUFF_SIZ, + &rd, (LPOVERLAPPED)&overlap[0]); if (iostat && rd != 0) { overlap[0].stat = 0; WriteFile(ppipe[PIPE_STDOUT_RPC], overlap[0].buff, rd, &wr, NULL); @@ -529,7 +522,7 @@ if (IS_VALID_HANDLE(pipes[PIPE_STDERR_RDS])) { if (overlap[1].stat == ERROR_IO_PENDING) { if (!GetOverlappedResult(pipes[PIPE_STDERR_RDS], - &overlap[1].o, + (LPOVERLAPPED)&overlap[1], &rd, FALSE)) { overlap[1].stat = GetLastError(); @@ -542,8 +535,8 @@ break; } iostat = ReadFile(pipes[PIPE_STDERR_RDS], - overlap[1].buff, PROC_BUFFER_SIZE, - &rd, &overlap[1].o); + overlap[1].buff, ACR_SBUFF_SIZ, + &rd, (LPOVERLAPPED)&overlap[1]); if (iostat && rd != 0) { overlap[1].stat = 0; WriteFile(ppipe[PIPE_STDERR_RPC], overlap[1].buff, rd, &wr, NULL); @@ -570,7 +563,7 @@ child.data.iov_len > 0) { if (overlap[2].stat == ERROR_IO_PENDING) { if (!GetOverlappedResult(pipes[PIPE_STDINP_WRS], - &overlap[2].o, + (LPOVERLAPPED)&overlap[2], &wr, FALSE)) { overlap[2].stat = GetLastError(); @@ -584,7 +577,8 @@ break; } iostat = WriteFile(pipes[PIPE_STDINP_WRS], inpp, - child.data.iov_len, &wr, &overlap[2].o); + child.data.iov_len, &wr, + (LPOVERLAPPED)&overlap[2]); if (iostat && wr != 0) { child.data.iov_len -= wr; inpp += wr; @@ -708,13 +702,13 @@ wchar_t *args = NULL; wchar_t *envb = NULL; const char *inpp = NULL; - OVERLAPPED_BUFFER overlap[3]; + OVERLAPPED_SBUFF overlap[3]; DWORD dwCreationFlags = CREATE_UNICODE_ENVIRONMENT | CREATE_SUSPENDED; acr_time_t endat = 0; - ACR_MEMZERO(PROCESS_INFORMATION, &pi, 1); - ACR_MEMZERO(STARTUPINFOW, &si, 1); - ACR_MEMZERO(OVERLAPPED_BUFFER, overlap, 3); + ACR_MEMZERO(PROCESS_INFORMATION, &pi, 1); + ACR_MEMZERO(STARTUPINFOW, &si, 1); + ACR_MEMZERO(OVERLAPPED_SBUFF, overlap, 3); si.cb = sizeof(si); @@ -737,7 +731,7 @@ } if (stubexe) - suba[0] = x_wcsdup(stubexe); + suba[0] = ACR_wcsdup(stubexe); else suba[0] = ACR_StrvcatW(THROW_NEVER, sysroot, L"\\System32\\RUNDLL32.EXE", NULL); @@ -790,7 +784,7 @@ suba[subn] = s_malloc(wchar_t, 64); _snwprintf(suba[subn++], 64, L"--E:%s", childpname[PIPE_STDERR_RPC] + 9); } - suba[subn++] = x_wcsdup(executable); + suba[subn++] = ACR_wcsdup(executable); suba[subn] = NULL; /* Merge the new array with the provided arguments */ @@ -982,7 +976,7 @@ if (IS_VALID_HANDLE(childpipes[PIPE_STDOUT_RPC])) { if (overlap[0].stat == ERROR_IO_PENDING) { if (!GetOverlappedResult(childpipes[PIPE_STDOUT_RPC], - &overlap[0].o, + (LPOVERLAPPED)&overlap[0], &rd, FALSE)) { overlap[0].stat = GetLastError(); @@ -995,8 +989,8 @@ break; } iostat = ReadFile(childpipes[PIPE_STDOUT_RPC], - overlap[0].buff, PROC_BUFFER_SIZE, - &rd, &overlap[0].o); + overlap[0].buff, ACR_SBUFF_SIZ, + &rd, (LPOVERLAPPED)&overlap[0]); if (iostat && rd != 0) { overlap[0].stat = 0; rd = acr_sbuf_bcat(&ep->sout, overlap[0].buff, rd); @@ -1021,7 +1015,7 @@ if (IS_VALID_HANDLE(childpipes[PIPE_STDERR_RPC])) { if (overlap[1].stat == ERROR_IO_PENDING) { if (!GetOverlappedResult(childpipes[PIPE_STDERR_RPC], - &overlap[1].o, + (LPOVERLAPPED)&overlap[1], &rd, FALSE)) { overlap[1].stat = GetLastError(); @@ -1034,8 +1028,8 @@ break; } iostat = ReadFile(childpipes[PIPE_STDERR_RPC], - overlap[1].buff, PROC_BUFFER_SIZE, - &rd, &overlap[1].o); + overlap[1].buff, ACR_SBUFF_SIZ, + &rd, (LPOVERLAPPED)&overlap[1]); if (iostat && rd != 0) { overlap[1].stat = 0; rd = acr_sbuf_bcat(&ep->sout, overlap[1].buff, rd); @@ -1060,7 +1054,7 @@ ep->data.iov_len > 0) { if (overlap[2].stat == ERROR_IO_PENDING) { if (!GetOverlappedResult(childpipes[PIPE_STDINP_RPC], - &overlap[2].o, + (LPOVERLAPPED)&overlap[2], &wr, FALSE)) { overlap[2].stat = GetLastError(); @@ -1079,7 +1073,8 @@ break; } iostat = WriteFile(childpipes[PIPE_STDINP_RPC], inpp, - ep->data.iov_len, &wr, &overlap[2].o); + ep->data.iov_len, &wr, + (LPOVERLAPPED)&overlap[2]); ACR_DEBUG((THROW_FMARK, "Written %d", wr)); if (iostat && wr != 0) { ep->data.iov_len -= wr; Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/subsys.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/subsys.c?rev=899585&r1=899584&r2=899585&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/win32/subsys.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/subsys.c Fri Jan 15 10:38:48 2010 @@ -59,7 +59,7 @@ fflush(stderr); goto cleanup; } - if ((rc = ACR_PlatformInitialize(INVALID_HANDLE_VALUE, 0))) { + if ((rc = ACR_PlatformInitialize(INVALID_JNIENV, 0))) { fprintf(stderr, "Failed to initialize the ACR platform error=%d\n", rc); fflush(stderr); goto cleanup; @@ -86,7 +86,7 @@ fflush(stderr); goto cleanup; } - if ((rc = ACR_PlatformInitialize(INVALID_HANDLE_VALUE, 0))) { + if ((rc = ACR_PlatformInitialize(INVALID_JNIENV, 0))) { fprintf(stderr, "Failed to initialize the ACR platform error=%d\n", rc); fflush(stderr); goto cleanup; Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/temps.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/temps.c?rev=899585&r1=899584&r2=899585&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/win32/temps.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/temps.c Fri Jan 15 10:38:48 2010 @@ -128,7 +128,7 @@ sa.nLength = sizeof(SECURITY_ATTRIBUTES); /* Allow access only to owner and Administrators Group */ - sa.lpSecurityDescriptor = ACR_StdSecurityDescriptor(INVALID_HANDLE_VALUE, + sa.lpSecurityDescriptor = ACR_StdSecurityDescriptor(INVALID_JNIENV, ACR_DT_FILE, ACR_FPROT_URWX | ACR_FPROT_GRWX); Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/wusec.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/wusec.c?rev=899585&r1=899584&r2=899585&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/win32/wusec.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/wusec.c Fri Jan 15 10:38:48 2010 @@ -532,7 +532,7 @@ LPVOID psd; SE_OBJECT_TYPE ko = SE_UNKNOWN_OBJECT_TYPE; - psd = ACR_GetSecurityDescriptor(INVALID_HANDLE_VALUE, + psd = ACR_GetSecurityDescriptor(INVALID_JNIENV, convert_acc(perms, type, &ko, prot_scope_user), convert_acc(perms, type, &ko, prot_scope_group), convert_acc(perms, type, &ko, prot_scope_world)); Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c?rev=899585&r1=899584&r2=899585&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c Fri Jan 15 10:38:48 2010 @@ -112,13 +112,13 @@ wchar_t *pipe_name_from_pid(wchar_t *rname, int pid, int id) { DWORD rc = 0; - wchar_t pname[64]; + wchar_t pname[128]; if (id == 0) id = ACR_AtomicInc32(&resource_id); wcscpy(rname, L"\\\\.\\pipe\\"); _snwprintf(pname, sizeof(pname), - L"apache-commons-pipe-%08x-%08x", pid, id); + L"apache-commons-runtime-pipe-%08x-%08x", pid, id); ACR_MD5EncUuidW(pname, wcslen(pname), rname + 9); return rname; } Modified: commons/sandbox/runtime/trunk/src/main/native/shared/args.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/args.c?rev=899585&r1=899584&r2=899585&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/shared/args.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/shared/args.c Fri Jan 15 10:38:48 2010 @@ -509,7 +509,7 @@ */ return numargs; } - cmds = x_strdup(cmdline); + cmds = ACR_strdup(cmdline); if (!cmds) return -1; *argv = s_calloc(char *, numargs); @@ -529,10 +529,9 @@ if (*cp == '*' && *(cp + 1) == '\0') { if (argidx <= nparams) break; - argument = x_strdup(params[argidx++]); + argument = ACR_strdup(params[argidx++]); for (; argidx < nparams; argidx++) { - argument = ACR_StrvcatA(INVALID_HANDLE_VALUE, - THROW_NMARK, + argument = ACR_StrvcatA(THROW_NEVER, argument, " ", params[argidx], NULL); @@ -548,7 +547,7 @@ */ break; } - (*argv)[argnum] = x_strdup((*argv)[0]); + (*argv)[argnum] = ACR_strdup((*argv)[0]); continue; } else if (argidx <= nparams) { @@ -563,7 +562,7 @@ } } } - (*argv)[argnum] = ACR_ArgumentExpandA(x_strdup(argument), NULL, NULL); + (*argv)[argnum] = ACR_ArgumentExpandA(ACR_strdup(argument), NULL, NULL); } x_free(cmds); @@ -604,7 +603,7 @@ */ return numargs; } - cmds = x_wcsdup(cmdline); + cmds = ACR_wcsdup(cmdline); if (!cmds) return -1; *argv = s_calloc(wchar_t *, numargs); @@ -624,10 +623,9 @@ if (*cp == L'*' && *(cp + 1) == L'\0') { if (argidx >= nparams) break; - argument = x_wcsdup(params[argidx++]); + argument = ACR_wcsdup(params[argidx++]); for (; argidx < nparams; argidx++) { - argument = ACR_StrvcatW(INVALID_HANDLE_VALUE, - THROW_NMARK, + argument = ACR_StrvcatW(THROW_NEVER, argument, L" ", params[argidx], NULL); @@ -643,7 +641,7 @@ */ break; } - (*argv)[argnum] = x_wcsdup((*argv)[0]); + (*argv)[argnum] = ACR_wcsdup((*argv)[0]); continue; } else if (argidx <= nparams) { @@ -658,7 +656,7 @@ } } } - (*argv)[argnum] = ACR_ArgumentExpandW(x_wcsdup(argument), NULL, NULL); + (*argv)[argnum] = ACR_ArgumentExpandW(ACR_wcsdup(argument), NULL, NULL); } x_free(cmds);