commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r907600 - in /commons/proper/daemon/trunk/src/native/nt/procrun/src: cmdline.c javajni.c service.c
Date Mon, 08 Feb 2010 09:42:13 GMT
Author: mturk
Date: Mon Feb  8 09:42:12 2010
New Revision: 907600

URL: http://svn.apache.org/viewvc?rev=907600&view=rev
Log:
Use safer strcpy/strcat variant

Modified:
    commons/proper/daemon/trunk/src/native/nt/procrun/src/cmdline.c
    commons/proper/daemon/trunk/src/native/nt/procrun/src/javajni.c
    commons/proper/daemon/trunk/src/native/nt/procrun/src/service.c

Modified: commons/proper/daemon/trunk/src/native/nt/procrun/src/cmdline.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/nt/procrun/src/cmdline.c?rev=907600&r1=907599&r2=907600&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/nt/procrun/src/cmdline.c (original)
+++ commons/proper/daemon/trunk/src/native/nt/procrun/src/cmdline.c Mon Feb  8 09:42:12 2010
@@ -252,8 +252,8 @@
     while (lpCmdline->lpOptions[i].szName) {
         DWORD l;
         WCHAR szVar[SIZ_HUGLEN];
-        lstrcpyW(szEnv, L"PR_");
-        lstrcatW(szEnv, lpCmdline->lpOptions[i].szName);
+        lstrlcpyW(szEnv, SIZ_HUGLEN, L"PR_");
+        lstrlcatW(szEnv, SIZ_HUGLEN, lpCmdline->lpOptions[i].szName);
         l = GetEnvironmentVariableW(szEnv, szVar, SIZ_HUGMAX);
         if (l == 0 && GetLastError() !=  ERROR_ENVVAR_NOT_FOUND) {
             apxLogWrite(APXLOG_MARK_ERROR "Error geting environment variable %S",
@@ -292,4 +292,4 @@
         ++i;
     }
 
-}
\ No newline at end of file
+}

Modified: commons/proper/daemon/trunk/src/native/nt/procrun/src/javajni.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/nt/procrun/src/javajni.c?rev=907600&r1=907599&r2=907600&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/nt/procrun/src/javajni.c (original)
+++ commons/proper/daemon/trunk/src/native/nt/procrun/src/javajni.c Mon Feb  8 09:42:12 2010
@@ -179,7 +179,7 @@
         WCHAR  jreBinPath[1024];
         DWORD  i, l = 0;
 
-        lstrcpynW(jreBinPath, dllJvmPath, 1023);
+        lstrlcpyW(jreBinPath, 1024, dllJvmPath);
         DYNLOAD_FPTR_ADDRESS(SetDllDirectoryW, KERNEL32);
         for (i = lstrlenW(jreBinPath); i > 0, l < 2; i--) {
             if (jreBinPath[i] == L'\\' || jreBinPath[i] == L'/') {
@@ -474,8 +474,8 @@
 
     if (!szMethodName)
         szMethodName = "main";
-    lstrcpyA(lpJava->clWorker.sClazz,  szClassName);
-    lstrcpyA(lpJava->clWorker.sMethod, szMethodName);
+    lstrlcpyA(lpJava->clWorker.sClazz, 1024, szClassName);
+    lstrlcpyA(lpJava->clWorker.sMethod, 512, szMethodName);
     lpJava->clWorker.jMethod = JNICALL_3(GetStaticMethodID,
                                          lpJava->clWorker.jClazz,
                                          szMethodName, "([Ljava/lang/String;)V");

Modified: commons/proper/daemon/trunk/src/native/nt/procrun/src/service.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/nt/procrun/src/service.c?rev=907600&r1=907599&r2=907600&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/nt/procrun/src/service.c (original)
+++ commons/proper/daemon/trunk/src/native/nt/procrun/src/service.c Mon Feb  8 09:42:12 2010
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
- 
+
 #include "apxwin.h"
 #include "private.h"
 
@@ -34,7 +34,7 @@
     /* Handle to the current service */
     SC_HANDLE       hService;
     /* Handle of the Service manager */
-    SC_HANDLE       hManager;     
+    SC_HANDLE       hManager;
     APXSERVENTRY    stServiceEntry;
 
 } APXSERVICE, *LPAPXSERVICE;
@@ -74,7 +74,7 @@
 {
     APXHANDLE    hService;
     LPAPXSERVICE lpService;
-    SC_HANDLE    hManager; 
+    SC_HANDLE    hManager;
 
     if (!(hManager = OpenSCManager(NULL, NULL, dwOptions))) {
         apxLogWrite(APXLOG_MARK_SYSERR);
@@ -126,7 +126,7 @@
         apxLogWrite(APXLOG_MARK_SYSERR);
         return FALSE;
     }
-    lstrcpyW(lpService->stServiceEntry.szServiceName, szServiceName);
+    lstrlcpyW(lpService->stServiceEntry.szServiceName, SIZ_RESLEN, szServiceName);
     if (!apxGetServiceDescriptionW(szServiceName,
                                    lpService->stServiceEntry.szServiceDescription,
                                    SIZ_DESLEN)) {
@@ -173,7 +173,7 @@
     return &lpService->stServiceEntry;
 }
 
-/* Set the service names etc... 
+/* Set the service names etc...
  * If the ImagePath contains a space, it must be quoted
  */
 BOOL
@@ -298,7 +298,7 @@
                 break;
             default:
                 break;
-        }     
+        }
     }
     if (!dwPending && !dwState)
         return FALSE;
@@ -310,7 +310,7 @@
     /* signal that we are about to control the service */
     if (fnControlCallback)
         (*fnControlCallback)(lpCbData, uMsg, (WPARAM)1, (LPARAM)dwState);
-    if (dwControl == SERVICE_CONTROL_CONTINUE && 
+    if (dwControl == SERVICE_CONTROL_CONTINUE &&
         stStatus.dwCurrentState != SERVICE_PAUSED)
         bStatus = StartService(lpService->hService, 0, NULL);
     else
@@ -321,9 +321,9 @@
         Sleep(100); /* Initial Sleep period */
         while (QueryServiceStatus(lpService->hService, &stStatus)) {
             if (stStatus.dwCurrentState == dwPending) {
-                /* Do not wait longer than the wait hint. A good interval is 
-                 * one tenth the wait hint, but no less than 1 second and no 
-                 * more than 10 seconds. 
+                /* Do not wait longer than the wait hint. A good interval is
+                 * one tenth the wait hint, but no less than 1 second and no
+                 * more than 10 seconds.
                  */
                 dwWait = stStatus.dwWaitHint / 10;
 
@@ -354,7 +354,7 @@
             }
             else
                 break;
-        }         
+        }
     }
     /* signal that we are done with controling the service */
     if (fnControlCallback)
@@ -423,7 +423,8 @@
         return FALSE;
     }
     else {
-        lstrcpyW(lpService->stServiceEntry.szServiceName, szServiceName);
+        lstrlcpyW(lpService->stServiceEntry.szServiceName,
+                  SIZ_RESLEN, szServiceName);
         lpService->stServiceEntry.dwStart = dwStartType;
         return TRUE;
     }
@@ -451,7 +452,7 @@
         rv = DeleteService(lpService->hService);
         SAFE_CLOSE_SCH(lpService->hService);
         SAFE_CLOSE_SCH(lpService->hManager);
-     
+
         return rv;
     }
     return FALSE;
@@ -459,7 +460,7 @@
 
 /* Browse the services */
 DWORD
-apxServiceBrowse(APXHANDLE hService, 
+apxServiceBrowse(APXHANDLE hService,
                  LPCWSTR szIncludeNamePattern,
                  LPCWSTR szIncludeImagePattern,
                  LPCWSTR szExcludeNamePattern,
@@ -539,7 +540,7 @@
                         if (_st_apx_oslevel >= 4) {
                             DWORD dwNeed;
                             QueryServiceStatusEx(hSrv, SC_STATUS_PROCESS_INFO,
-                                                 (LPBYTE)(&(stEntry.stStatusProcess)),

+                                                 (LPBYTE)(&(stEntry.stStatusProcess)),
                                                  sizeof(SERVICE_STATUS_PROCESS),
                                                  &dwNeed);
                         }



Mime
View raw message