tests/server/util.c: use curl_off_t instead of long for pid

Avoid potential overflow of huge PIDs on Windows.

Related to #5188
Assisted-by: Marcel Raad
This commit is contained in:
Marc Hoersken 2020-04-11 23:40:45 +02:00
parent c1951cdb38
commit dd0365d560
No known key found for this signature in database
GPG Key ID: 61E03CBED7BC859E
1 changed files with 3 additions and 3 deletions

View 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 */