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 2011/11/04 11:12:10 UTC
svn commit: r1197479 - in /commons/proper/daemon/trunk/src/native/windows:
apps/prunsrv/prunsrv.c include/apxwin.h src/utils.c
Author: mturk
Date: Fri Nov 4 10:12:10 2011
New Revision: 1197479
URL: http://svn.apache.org/viewvc?rev=1197479&view=rev
Log:
DAEMON-219: Prevent crashing procrun by making sure we use java.lang.System if --StopClass was not defined
Modified:
commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c
commons/proper/daemon/trunk/src/native/windows/include/apxwin.h
commons/proper/daemon/trunk/src/native/windows/src/utils.c
Modified: commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c?rev=1197479&r1=1197478&r2=1197479&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c (original)
+++ commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c Fri Nov 4 10:12:10 2011
@@ -1346,8 +1346,13 @@ void WINAPI serviceMain(DWORD argc, LPTS
if (!lstrcmpiW(SO_STOPMODE, PRSRV_JVM)) {
_jni_shutdown = TRUE;
_jni_sclass = WideToANSI(SO_STOPCLASS);
- apxStrCharReplaceA(_jni_sclass, '.', '/');
- _jni_sparam = SO_STOPPARAMS;
+ if (IS_VALID_STRING(SO_STOPCLASS)) {
+ apxStrCharReplaceA(_jni_sclass, '.', '/');
+ _jni_sparam = SO_STOPPARAMS;
+ }
+ else {
+ _jni_sclass = "java/lang/System";
+ }
}
else if (!lstrcmpiW(SO_STOPMODE, PRSRV_JAVA)) {
LPWSTR jx = NULL, szJH = SO_JAVAHOME;
Modified: commons/proper/daemon/trunk/src/native/windows/include/apxwin.h
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/windows/include/apxwin.h?rev=1197479&r1=1197478&r2=1197479&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/windows/include/apxwin.h (original)
+++ commons/proper/daemon/trunk/src/native/windows/include/apxwin.h Fri Nov 4 10:12:10 2011
@@ -63,6 +63,7 @@ typedef _W64 int intptr_t;
#define IS_INVALID_HANDLE(h) (((h) == NULL || (h) == INVALID_HANDLE_VALUE))
#define IS_VALID_STRING(s) ((s) != NULL && *(s) != 0)
+#define IS_EMPTY_STRING(s) ((s) == NULL || *(s) == 0)
#define DYNOLAD_TYPE_DECLARE(fnName, callconv, retType) \
typedef retType (callconv *PFN_##fnName) \
Modified: commons/proper/daemon/trunk/src/native/windows/src/utils.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/windows/src/utils.c?rev=1197479&r1=1197478&r2=1197479&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/windows/src/utils.c (original)
+++ commons/proper/daemon/trunk/src/native/windows/src/utils.c Fri Nov 4 10:12:10 2011
@@ -499,6 +499,8 @@ LPTSTR apxStrCharRemove(LPTSTR szString,
{
LPTSTR p = szString;
LPTSTR q = szString;
+ if (IS_EMPTY_STRING(szString))
+ return szString;
while (*p) {
if(*p != chSkip)
*q++ = *p;
@@ -514,6 +516,8 @@ DWORD apxStrCharRemoveA(LPSTR szString,
LPSTR p = szString;
LPSTR q = szString;
DWORD c = 0;
+ if (IS_EMPTY_STRING(szString))
+ return c;
while (*p) {
if(*p != chSkip)
*q++ = *p;
@@ -531,6 +535,8 @@ DWORD apxStrCharRemoveW(LPWSTR szString,
LPWSTR p = szString;
LPWSTR q = szString;
DWORD c = 0;
+ if (IS_EMPTY_STRING(szString))
+ return c;
while (*p) {
if(*p != chSkip)
*q++ = *p;
@@ -548,6 +554,9 @@ apxStrCharReplaceA(LPSTR szString, CHAR
{
LPSTR p = szString;
LPSTR q = szString;
+
+ if (IS_EMPTY_STRING(szString))
+ return;
while (*p) {
if(*p == chReplace)
*q++ = chReplaceWith;
@@ -563,6 +572,8 @@ apxStrCharReplaceW(LPWSTR szString, WCHA
{
LPWSTR p = szString;
LPWSTR q = szString;
+ if (IS_EMPTY_STRING(szString))
+ return;
while (*p) {
if(*p == chReplace)
*q++ = chReplaceWith;
Re: svn commit: r1197479 - in /commons/proper/daemon/trunk/src/native/windows:
apps/prunsrv/prunsrv.c include/apxwin.h src/utils.c
Posted by sebb <se...@gmail.com>.
On 4 November 2011 10:12, <mt...@apache.org> wrote:
> Author: mturk
> Date: Fri Nov 4 10:12:10 2011
> New Revision: 1197479
>
> URL: http://svn.apache.org/viewvc?rev=1197479&view=rev
> Log:
> DAEMON-219: Prevent crashing procrun by making sure we use java.lang.System if --StopClass was not defined
Would it be possible to report an error instead during parameter validation?
> Modified:
> commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c
> commons/proper/daemon/trunk/src/native/windows/include/apxwin.h
> commons/proper/daemon/trunk/src/native/windows/src/utils.c
>
> Modified: commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c
> URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c?rev=1197479&r1=1197478&r2=1197479&view=diff
> ==============================================================================
> --- commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c (original)
> +++ commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c Fri Nov 4 10:12:10 2011
> @@ -1346,8 +1346,13 @@ void WINAPI serviceMain(DWORD argc, LPTS
> if (!lstrcmpiW(SO_STOPMODE, PRSRV_JVM)) {
> _jni_shutdown = TRUE;
> _jni_sclass = WideToANSI(SO_STOPCLASS);
> - apxStrCharReplaceA(_jni_sclass, '.', '/');
> - _jni_sparam = SO_STOPPARAMS;
> + if (IS_VALID_STRING(SO_STOPCLASS)) {
> + apxStrCharReplaceA(_jni_sclass, '.', '/');
> + _jni_sparam = SO_STOPPARAMS;
> + }
> + else {
> + _jni_sclass = "java/lang/System";
> + }
> }
> else if (!lstrcmpiW(SO_STOPMODE, PRSRV_JAVA)) {
> LPWSTR jx = NULL, szJH = SO_JAVAHOME;
>
> Modified: commons/proper/daemon/trunk/src/native/windows/include/apxwin.h
> URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/windows/include/apxwin.h?rev=1197479&r1=1197478&r2=1197479&view=diff
> ==============================================================================
> --- commons/proper/daemon/trunk/src/native/windows/include/apxwin.h (original)
> +++ commons/proper/daemon/trunk/src/native/windows/include/apxwin.h Fri Nov 4 10:12:10 2011
> @@ -63,6 +63,7 @@ typedef _W64 int intptr_t;
>
> #define IS_INVALID_HANDLE(h) (((h) == NULL || (h) == INVALID_HANDLE_VALUE))
> #define IS_VALID_STRING(s) ((s) != NULL && *(s) != 0)
> +#define IS_EMPTY_STRING(s) ((s) == NULL || *(s) == 0)
>
> #define DYNOLAD_TYPE_DECLARE(fnName, callconv, retType) \
> typedef retType (callconv *PFN_##fnName) \
>
> Modified: commons/proper/daemon/trunk/src/native/windows/src/utils.c
> URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/windows/src/utils.c?rev=1197479&r1=1197478&r2=1197479&view=diff
> ==============================================================================
> --- commons/proper/daemon/trunk/src/native/windows/src/utils.c (original)
> +++ commons/proper/daemon/trunk/src/native/windows/src/utils.c Fri Nov 4 10:12:10 2011
> @@ -499,6 +499,8 @@ LPTSTR apxStrCharRemove(LPTSTR szString,
> {
> LPTSTR p = szString;
> LPTSTR q = szString;
> + if (IS_EMPTY_STRING(szString))
> + return szString;
> while (*p) {
> if(*p != chSkip)
> *q++ = *p;
> @@ -514,6 +516,8 @@ DWORD apxStrCharRemoveA(LPSTR szString,
> LPSTR p = szString;
> LPSTR q = szString;
> DWORD c = 0;
> + if (IS_EMPTY_STRING(szString))
> + return c;
> while (*p) {
> if(*p != chSkip)
> *q++ = *p;
> @@ -531,6 +535,8 @@ DWORD apxStrCharRemoveW(LPWSTR szString,
> LPWSTR p = szString;
> LPWSTR q = szString;
> DWORD c = 0;
> + if (IS_EMPTY_STRING(szString))
> + return c;
> while (*p) {
> if(*p != chSkip)
> *q++ = *p;
> @@ -548,6 +554,9 @@ apxStrCharReplaceA(LPSTR szString, CHAR
> {
> LPSTR p = szString;
> LPSTR q = szString;
> +
> + if (IS_EMPTY_STRING(szString))
> + return;
> while (*p) {
> if(*p == chReplace)
> *q++ = chReplaceWith;
> @@ -563,6 +572,8 @@ apxStrCharReplaceW(LPWSTR szString, WCHA
> {
> LPWSTR p = szString;
> LPWSTR q = szString;
> + if (IS_EMPTY_STRING(szString))
> + return;
> while (*p) {
> if(*p == chReplace)
> *q++ = chReplaceWith;
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org