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/10/02 15:08:30 UTC

svn commit: r1003792 - in /commons/proper/daemon/trunk/src/native/windows: apps/prunsrv/prunsrv.c src/registry.c

Author: mturk
Date: Sat Oct  2 13:08:30 2010
New Revision: 1003792

URL: http://svn.apache.org/viewvc?rev=1003792&view=rev
Log:
Guard against invalid and missing service name. Display human readable error

Modified:
    commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c
    commons/proper/daemon/trunk/src/native/windows/src/registry.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=1003792&r1=1003791&r2=1003792&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 Sat Oct  2 13:08:30 2010
@@ -385,6 +385,11 @@ static BOOL loadConfiguration(LPAPXCMDLI
     APXHANDLE hRegistry;
     int i = 0;
 
+    if (!lpCmdline->szApplication) {
+        /* Handle empty service names */
+        apxLogWrite(APXLOG_MARK_WARN "No service name provided");
+        return FALSE;           
+    }
     SetLastError(ERROR_SUCCESS);
     hRegistry = apxCreateRegistryW(gPool, KEY_READ | KREG_WOW6432,
                                    PRG_REGROOT,

Modified: commons/proper/daemon/trunk/src/native/windows/src/registry.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/windows/src/registry.c?rev=1003792&r1=1003791&r2=1003792&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/windows/src/registry.c (original)
+++ commons/proper/daemon/trunk/src/native/windows/src/registry.c Sat Oct  2 13:08:30 2010
@@ -236,10 +236,14 @@ apxCreateRegistryW(APXHANDLE hPool, REGS
     HKEY      hSparamKey = NULL;
     HKEY      hUparamKey = NULL;
 
-    if (!szKeyName || lstrlenW(szKeyName) > SIZ_RESMAX)
+    if (!szKeyName || lstrlenW(szKeyName) > SIZ_RESMAX) {
+        SetLastError(ERROR_INVALID_PARAMETER);
         return NULL;
-    if (szRoot && lstrlenW(szRoot) > SIZ_RESMAX)
+    }
+    if (szRoot && lstrlenW(szRoot) > SIZ_RESMAX) {
+        SetLastError(ERROR_INVALID_PARAMETER);
         return NULL;
+    }
 
     /* make the HKLM\\SOFTWARE key */
     lstrcpyW(buff, REGSOFTWARE_ROOT);