1. Daniel Cid
  2. ossec-hids

Commits

Daniel Cid  committed 05602f1

Fixing insecure path creation for the winsrvc.

Reported by Justin Kelly justin at justinsteven.com (thanks!)

  • Participants
  • Parent commits a2ef289
  • Branches default

Comments (0)

Files changed (1)

File src/win32/win_agent.c

View file
  • Ignore whitespace
 {
     char *tmpstr;
     char mypath[OS_MAXSTR +1];
+    char myfinalpath[OS_MAXSTR +1];
     char myfile[OS_MAXSTR +1];
 
     /* Setting the name */
 
     /* Find where I'm */
     mypath[OS_MAXSTR] = '\0';
+    myfinalpath[OS_MAXSTR] = '\0';
     myfile[OS_MAXSTR] = '\0';
     
     
     }
     chdir(mypath);
     getcwd(mypath, OS_MAXSTR -1);
-    strncat(mypath, "\\", OS_MAXSTR - (strlen(mypath) + 2));
-    strncat(mypath, myfile, OS_MAXSTR - (strlen(mypath) + 2));
+    snprintf(myfinalpath, OS_MAXSTR, "\"%s\\%s\"", mypath, myfile);
     
      
     if(argc > 1)
     {
         if(strcmp(argv[1], "install-service") == 0)
         {
-            return(InstallService(mypath));
+            return(InstallService(myfinalpath));
         }
         else if(strcmp(argv[1], "uninstall-service") == 0)
         {