gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r26954 - gnunet/contrib


From: gnunet
Subject: [GNUnet-SVN] r26954 - gnunet/contrib
Date: Sun, 21 Apr 2013 15:36:59 +0200

Author: LRN
Date: 2013-04-21 15:36:59 +0200 (Sun, 21 Apr 2013)
New Revision: 26954

Modified:
   gnunet/contrib/timeout_watchdog_w32.c
Log:
Use safer functions in w32 watchdog

Modified: gnunet/contrib/timeout_watchdog_w32.c
===================================================================
--- gnunet/contrib/timeout_watchdog_w32.c       2013-04-21 13:36:55 UTC (rev 
26953)
+++ gnunet/contrib/timeout_watchdog_w32.c       2013-04-21 13:36:59 UTC (rev 
26954)
@@ -37,7 +37,6 @@
   wchar_t **wargv;
   wchar_t *arg;
   unsigned int cmdlen;
-  wchar_t *idx;
   STARTUPINFOW start;
   PROCESS_INFORMATION proc;
 
@@ -50,6 +49,7 @@
   wchar_t *wcmd;
   int wargc;
   int timeout = 0;
+  ssize_t wrote;
 
   HANDLE job;
 
@@ -125,22 +125,25 @@
   while (NULL != (arg = wargv[i++]))
     cmdlen += wcslen (arg) + 4;
 
-  wcmd = idx = malloc (sizeof (wchar_t) * (cmdlen + 1));
+  wcmd = malloc (sizeof (wchar_t) * (cmdlen + 1));
+  wrote = 0;
   i = 2;
   while (NULL != (arg = wargv[i++]))
   {
     /* This is to escape trailing slash */
     wchar_t arg_lastchar = arg[wcslen (arg) - 1];
-    if (idx == wcmd)
-      idx += swprintf (idx, L"\"%s%s\" ", wpath,
+    if (wrote == 0)
+    {
+      wrote += _snwprintf (&wcmd[wrote], cmdlen + 1 - wrote, L"\"%s%s\" ", 
wpath,
           arg_lastchar == L'\\' ? L"\\" : L"");
+    }
     else
     {
       if (wcschr (arg, L' ') != NULL)
-        idx += swprintf (idx, L"\"%s%s\"%s", arg,
+        wrote += swprintf (&wcmd[wrote], cmdlen + 1 - wrote, L"\"%s%s\"%s", 
arg,
             arg_lastchar == L'\\' ? L"\\" : L"", i == wargc ? L"" : L" ");
       else
-        idx += swprintf (idx, L"%s%s%s", arg,
+        wrote += swprintf (&wcmd[wrote], cmdlen + 1 - wrote, L"%s%s%s", arg,
             arg_lastchar == L'\\' ? L"\\" : L"", i == wargc ? L"" : L" ");
     }
   }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]