View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001570 | GNUnet | ARM service | public | 2010-06-20 18:34 | 2011-10-05 22:21 |
Reporter | LRN | Assigned To | NDurner | ||
Priority | normal | Severity | major | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Summary | 0001570: ARM fails to launch processes due to the lack of ".exe" extension in executable file names | ||||
Description | CreateProcess() does not assume any default file extensions and fails with ERROR_FILE_NOT_FOUND when invoked with incomplete filename. Patch attached (also fixes some memory corruption issues). | ||||
Tags | No tags attached. | ||||
Attached Files | win32_arm.diff (2,363 bytes)
Index: src/util/os_priority.c =================================================================== --- src/util/os_priority.c (revision 11817) +++ src/util/os_priority.c (working copy) @@ -370,22 +370,62 @@ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "execvp", filename); _exit (1); #else - char **arg; + char **arg, **non_const_argv; unsigned int cmdlen; char *cmd, *idx; STARTUPINFO start; PROCESS_INFORMATION proc; + int argcount = 0; + char *non_const_filename = NULL; + int filenamelen = 0; - cmdlen = 0; + /* Count the number of arguments */ arg = argv; while (*arg) { + arg++; + argcount++; + } + + /* Allocate a copy argv */ + non_const_argv = GNUNET_malloc (sizeof (char *) * (argcount + 1)); + + /* Copy all argv strings */ + argcount = 0; + arg = argv; + while (*arg) + { + non_const_argv[argcount] = GNUNET_strdup (*arg); + arg++; + argcount++; + } + non_const_argv[argcount] = NULL; + + /* Fix .exe extension */ + filenamelen = strlen (filename); + if (filenamelen <= 4 || stricmp (&filename[filenamelen - 4], ".exe") != 0) + { + non_const_filename = GNUNET_malloc (sizeof (char) * (filenamelen + 4 + 1)); + non_const_filename = strcpy (non_const_filename, non_const_argv[0]); + strcat (non_const_filename, ".exe"); + GNUNET_free (non_const_argv[0]); + non_const_argv[0] = non_const_filename; + } + else + non_const_filename = non_const_argv[0]; + + /* Count cmd len */ + cmdlen = 1; + arg = non_const_argv; + while (*arg) + { cmdlen = cmdlen + strlen (*arg) + 3; arg++; } + /* Allocate and create cmd */ cmd = idx = GNUNET_malloc (sizeof (char) * cmdlen); - arg = argv; + arg = non_const_argv; while (*arg) { idx += sprintf (idx, "\"%s\" ", *arg); @@ -396,7 +436,7 @@ start.cb = sizeof (start); if (!CreateProcess - (filename, cmd, NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &start, + (non_const_filename, cmd, NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &start, &proc)) { SetErrnoFromWinError (GetLastError ()); @@ -409,6 +449,10 @@ CloseHandle (proc.hThread); GNUNET_free (cmd); + while (argcount > 0) + GNUNET_free (non_const_argv[--argcount]); + GNUNET_free (non_const_argv); + return proc.dwProcessId; #endif } | ||||
Date Modified | Username | Field | Change |
---|---|---|---|
2010-06-20 18:34 | LRN | New Issue | |
2010-06-20 18:34 | LRN | File Added: win32_arm.diff | |
2010-06-20 18:44 | Christian Grothoff | Project | gnunet-qt => GNUnet |
2010-06-21 20:53 | NDurner | Note Added: 0004041 | |
2010-06-21 20:53 | NDurner | Status | new => resolved |
2010-06-21 20:53 | NDurner | Resolution | open => fixed |
2010-06-21 20:53 | NDurner | Assigned To | => NDurner |
2010-07-03 20:55 | Christian Grothoff | Status | resolved => closed |
2011-10-05 22:21 | Christian Grothoff | Category | => ARM service |