]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests/server/util.c: use curl_off_t instead of long for pid
authorMarc Hoersken <info@marc-hoersken.de>
Sat, 11 Apr 2020 21:40:45 +0000 (23:40 +0200)
committerMarc Hoersken <info@marc-hoersken.de>
Sat, 11 Apr 2020 21:46:30 +0000 (23:46 +0200)
Avoid potential overflow of huge PIDs on Windows.

Related to #5188
Assisted-by: Marcel Raad
tests/server/util.c

index fa3d45118d3de1b143b58e40d15805792e2f0490..24f9497ae45c7df431a28f3980fcb369c0d2b912 100644 (file)
@@ -261,9 +261,9 @@ int wait_ms(int timeout_ms)
 int write_pidfile(const char *filename)
 {
   FILE *pidfile;
-  long pid;
+  curl_off_t pid;
 
-  pid = (long)getpid();
+  pid = (curl_off_t)getpid();
   pidfile = fopen(filename, "wb");
   if(!pidfile) {
     logmsg("Couldn't write pid file: %s %s", filename, strerror(errno));
@@ -278,7 +278,7 @@ int write_pidfile(const char *filename)
    */
   pid += 65536;
 #endif
-  fprintf(pidfile, "%ld\n", pid);
+  fprintf(pidfile, "%" CURL_FORMAT_CURL_OFF_T "\n", pid);
   fclose(pidfile);
   logmsg("Wrote pid %ld to %s", pid, filename);
   return 1; /* success */