# SPDX-License-Identifier: curl
allowfunc accept
-allowfunc fclose
-allowfunc fopen
allowfunc fprintf
allowfunc freeaddrinfo
allowfunc getaddrinfo
snprintf(dumpfile, sizeof(dumpfile), "%s/dnsd.input", logdir);
/* Open request dump file. */
- server = fopen(dumpfile, "ab");
+ server = curlx_fopen(dumpfile, "ab");
if(!server) {
char errbuf[STRERROR_LEN];
int error = errno;
if(*qlen > qbuflen) {
logmsg("dnsd: query too large: %lu > %lu",
(unsigned long)*qlen, (unsigned long)qbuflen);
- fclose(server);
+ curlx_fclose(server);
return -1;
}
memcpy(qbuf, qptr, *qlen);
fprintf(server, "\n");
#endif
- fclose(server);
+ curlx_fclose(server);
return 0;
}
char file[256];
FILE *f;
snprintf(file, sizeof(file), "%s/" INSTRUCTIONS, logdir);
- f = fopen(file, FOPEN_READTEXT);
+ f = curlx_fopen(file, FOPEN_READTEXT);
if(f) {
char buf[256];
ancount_aaaa = ancount_a = 0;
}
}
}
- fclose(f);
+ curlx_fclose(f);
}
else
logmsg("Error opening file '%s'", file);
static void mqttd_getconfig(void)
{
- FILE *fp = fopen(configfile, FOPEN_READTEXT);
+ FILE *fp = curlx_fopen(configfile, FOPEN_READTEXT);
mqttd_resetdefaults();
if(fp) {
char buffer[512];
}
}
}
- fclose(fp);
+ curlx_fclose(fp);
}
else {
logmsg("No config file '%s' to read", configfile);
0x04 /* protocol level */
};
snprintf(dumpfile, sizeof(dumpfile), "%s/%s", logdir, REQUEST_DUMP);
- dump = fopen(dumpfile, "ab");
+ dump = curlx_fopen(dumpfile, "ab");
if(!dump)
goto end;
if(buffer)
free(buffer);
if(dump)
- fclose(dump);
+ curlx_fclose(dump);
if(stream)
- fclose(stream);
+ curlx_fclose(stream);
return CURL_SOCKET_BAD;
}
/* get the custom server control "commands" */
int error = getpart(&cmd, &cmdsize, "reply", "servercmd", stream);
- fclose(stream);
+ curlx_fclose(stream);
if(error) {
logmsg("getpart() failed with error (%d)", error);
req->open = FALSE; /* closes connection */
return;
do {
- dump = fopen(dumpfile, "ab");
+ dump = curlx_fopen(dumpfile, "ab");
/* !checksrc! disable ERRNOVAR 1 */
} while(!dump && ((error = errno) == EINTR));
if(!dump) {
storerequest_cleanup:
- res = fclose(dump);
+ res = curlx_fclose(dump);
if(res)
logmsg("Error closing file %s error (%d) %s", dumpfile,
errno, curlx_strerror(errno, errbuf, sizeof(errbuf)));
}
else {
error = getpart(&ptr, &count, "reply", partbuf, stream);
- fclose(stream);
+ curlx_fclose(stream);
if(error) {
logmsg("getpart() failed with error (%d)", error);
return 0;
else {
/* get the custom server control "commands" */
error = getpart(&cmd, &cmdsize, "reply", "postcmd", stream);
- fclose(stream);
+ curlx_fclose(stream);
if(error) {
logmsg("getpart() failed with error (%d)", error);
free(ptr);
else
rtspd_prevbounce = FALSE;
- dump = fopen(responsedump, "ab");
+ dump = curlx_fopen(responsedump, "ab");
if(!dump) {
error = errno;
logmsg("fopen() failed with error (%d) %s",
req->rtp_buffersize = 0;
}
- res = fclose(dump);
+ res = curlx_fclose(dump);
if(res)
logmsg("Error closing file %s error (%d) %s", responsedump,
errno, curlx_strerror(errno, errbuf, sizeof(errbuf)));
static void socksd_getconfig(void)
{
- FILE *fp = fopen(configfile, FOPEN_READTEXT);
+ FILE *fp = curlx_fopen(configfile, FOPEN_READTEXT);
socksd_resetdefaults();
if(fp) {
char buffer[512];
}
}
}
- fclose(fp);
+ curlx_fclose(fp);
}
}
{
FILE *dump;
- dump = fopen(reqlogfile, "ab");
+ dump = curlx_fopen(reqlogfile, "ab");
if(dump) {
int i;
fprintf(dump, "atyp %u =>", type);
fprintf(dump, "\n");
break;
}
- fclose(dump);
+ curlx_fclose(dump);
}
}
/* parse the file on disk that might have a test number for us */
static int parse_cmdfile(struct sws_httprequest *req)
{
- FILE *f = fopen(cmdfile, FOPEN_READTEXT);
+ FILE *f = curlx_fopen(cmdfile, FOPEN_READTEXT);
if(f) {
int testnum = DOCNUMBER_NOTHING;
char buf[256];
req->testno = testnum;
}
}
- fclose(f);
+ curlx_fclose(f);
}
return 0;
}
/* get the custom server control "commands" */
error = getpart(&orgcmd, &cmdsize, "reply", "servercmd", stream);
- fclose(stream);
+ curlx_fclose(stream);
if(error) {
logmsg("getpart() failed with error (%d)", error);
req->open = FALSE; /* closes connection */
return;
do {
- dump = fopen(dumpfile, "ab");
+ dump = curlx_fopen(dumpfile, "ab");
/* !checksrc! disable ERRNOVAR 1 */
} while(!dump && ((error = errno) == EINTR));
if(!dump) {
storerequest_cleanup:
- res = fclose(dump);
+ res = curlx_fclose(dump);
if(res)
logmsg("Error closing file %s error (%d) %s", dumpfile,
errno, curlx_strerror(errno, errbuf, sizeof(errbuf)));
}
else {
error = getpart(&ptr, &count, "reply", partbuf, stream);
- fclose(stream);
+ curlx_fclose(stream);
if(error) {
logmsg("getpart() failed with error (%d)", error);
return 0;
else {
/* get the custom server control "commands" */
error = getpart(&cmd, &cmdsize, "reply", "postcmd", stream);
- fclose(stream);
+ curlx_fclose(stream);
if(error) {
logmsg("getpart() failed with error (%d)", error);
free(ptr);
else
sws_prevbounce = FALSE;
- dump = fopen(responsedump, "ab");
+ dump = curlx_fopen(responsedump, "ab");
if(!dump) {
error = errno;
logmsg("fopen() failed with error (%d) %s",
}
} while((count > 0) && !got_exit_signal);
- res = fclose(dump);
+ res = curlx_fclose(dump);
if(res)
logmsg("Error closing file %s error (%d) %s", responsedump,
errno, curlx_strerror(errno, errbuf, sizeof(errbuf)));
if(!test->ofile) {
char outfile[256];
snprintf(outfile, sizeof(outfile), "%s/upload.%ld", logdir, test->testno);
- test->ofile = open(outfile, O_CREAT | O_RDWR | CURL_O_BINARY,
+ test->ofile = curlx_open(outfile, O_CREAT | O_RDWR | CURL_O_BINARY,
#ifdef _WIN32
- S_IREAD | S_IWRITE
+ S_IREAD | S_IWRITE
#else
- S_IRUSR | S_IWUSR | S_IXUSR |
- S_IRGRP | S_IWGRP | S_IXGRP |
- S_IROTH | S_IWOTH | S_IXOTH
+ S_IRUSR | S_IWUSR | S_IXUSR |
+ S_IRGRP | S_IWGRP | S_IXGRP |
+ S_IROTH | S_IWOTH | S_IXOTH
#endif
);
if(test->ofile == -1) {
snprintf(dumpfile, sizeof(dumpfile), "%s/%s", logdir, REQUEST_DUMP);
/* Open request dump file. */
- server = fopen(dumpfile, "ab");
+ server = curlx_fopen(dumpfile, "ab");
if(!server) {
char errbuf[STRERROR_LEN];
int error = errno;
if(*cp || !mode) {
nak(TFTP_EBADOP);
- fclose(server);
+ curlx_fclose(server);
return 3;
}
*cp = (char)tolower((int)*cp);
/* store input protocol */
- fclose(server);
+ curlx_fclose(server);
for(pf = formata; pf->f_mode; pf++)
if(strcmp(pf->f_mode, mode) == 0)
/* get the custom server control "commands" */
error = getpart(&orgcmd, &cmdsize, "reply", "servercmd", stream);
- fclose(stream);
+ curlx_fclose(stream);
if(error) {
logmsg("getpart() failed with error (%d)", error);
return 1; /* done */
else {
size_t count;
int error = getpart(&test->buffer, &count, "reply", partbuf, stream);
- fclose(stream);
+ curlx_fclose(stream);
if(error) {
logmsg("getpart() failed with error (%d)", error);
return TFTP_EACCESS;
va_end(ap);
do {
- logfp = fopen(serverlogfile, "ab");
+ logfp = curlx_fopen(serverlogfile, "ab");
/* !checksrc! disable ERRNOVAR 1 */
} while(!logfp && (errno == EINTR));
if(logfp) {
fprintf(logfp, "%s %s\n", timebuf, buffer);
- fclose(logfp);
+ curlx_fclose(logfp);
}
else {
char errbuf[STRERROR_LEN];
char filename[256];
/* first try the alternative, preprocessed, file */
snprintf(filename, sizeof(filename), "%s/test%ld", logdir2, testno);
- stream = fopen(filename, "rb");
+ stream = curlx_fopen(filename, "rb");
return stream;
}
curl_off_t pid;
pid = our_getpid();
- pidfile = fopen(filename, "wb");
+ pidfile = curlx_fopen(filename, "wb");
if(!pidfile) {
char errbuf[STRERROR_LEN];
logmsg("Could not write pid file: %s (%d) %s", filename,
return 0; /* fail */
}
fprintf(pidfile, "%ld\n", (long)pid);
- fclose(pidfile);
+ curlx_fclose(pidfile);
logmsg("Wrote pid %ld to %s", (long)pid, filename);
return 1; /* success */
}
/* store the used port number in a file */
int write_portfile(const char *filename, int port)
{
- FILE *portfile = fopen(filename, "wb");
+ FILE *portfile = curlx_fopen(filename, "wb");
if(!portfile) {
char errbuf[STRERROR_LEN];
logmsg("Could not write port file: %s (%d) %s", filename,
return 0; /* fail */
}
fprintf(portfile, "%d\n", port);
- fclose(portfile);
+ curlx_fclose(portfile);
logmsg("Wrote port %d to %s", port, filename);
return 1; /* success */
}
int res;
do {
- lockfile = fopen(filename, "wb");
+ lockfile = curlx_fopen(filename, "wb");
/* !checksrc! disable ERRNOVAR 1 */
} while(!lockfile && ((error = errno) == EINTR));
if(!lockfile) {
return;
}
- res = fclose(lockfile);
+ res = curlx_fclose(lockfile);
if(res)
logmsg("Error closing lock file %s error (%d) %s", filename,
errno, curlx_strerror(errno, errbuf, sizeof(errbuf)));