mirror of
https://github.com/moparisthebest/curl
synced 2025-01-11 14:08:07 -05:00
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:
parent
c1951cdb38
commit
dd0365d560
@ -261,9 +261,9 @@ int wait_ms(int timeout_ms)
|
|||||||
int write_pidfile(const char *filename)
|
int write_pidfile(const char *filename)
|
||||||
{
|
{
|
||||||
FILE *pidfile;
|
FILE *pidfile;
|
||||||
long pid;
|
curl_off_t pid;
|
||||||
|
|
||||||
pid = (long)getpid();
|
pid = (curl_off_t)getpid();
|
||||||
pidfile = fopen(filename, "wb");
|
pidfile = fopen(filename, "wb");
|
||||||
if(!pidfile) {
|
if(!pidfile) {
|
||||||
logmsg("Couldn't write pid file: %s %s", filename, strerror(errno));
|
logmsg("Couldn't write pid file: %s %s", filename, strerror(errno));
|
||||||
@ -278,7 +278,7 @@ int write_pidfile(const char *filename)
|
|||||||
*/
|
*/
|
||||||
pid += 65536;
|
pid += 65536;
|
||||||
#endif
|
#endif
|
||||||
fprintf(pidfile, "%ld\n", pid);
|
fprintf(pidfile, "%" CURL_FORMAT_CURL_OFF_T "\n", pid);
|
||||||
fclose(pidfile);
|
fclose(pidfile);
|
||||||
logmsg("Wrote pid %ld to %s", pid, filename);
|
logmsg("Wrote pid %ld to %s", pid, filename);
|
||||||
return 1; /* success */
|
return 1; /* success */
|
||||||
|
Loading…
Reference in New Issue
Block a user