fd = platform_open(file, O_RDONLY, 0);
if (fd == -1)
{
- msg(M_ERR, "Cannot open file key file '%s'", file);
+ msg(M_ERR, "Cannot open key file '%s'", file);
}
- size = read(fd, in.data, in.capacity);
+ size = platform_read(fd, in.data, in.capacity);
if (size < 0)
{
msg(M_FATAL, "Read error on key file ('%s')", file);
gc_free(&gc);
}
- /* Write our PID to a file */
- void
- write_pid(const char *filename)
- {
- if (filename)
- {
- unsigned int pid = 0;
- FILE *fp = platform_fopen(filename, "w");
- if (!fp)
- {
- msg(M_ERR, "Open error on pid file %s", filename);
- }
-
- pid = platform_getpid();
- fprintf(fp, "%u\n", pid);
- if (platform_fclose(fp))
- {
- msg(M_ERR, "Close error on pid file %s", filename);
- }
- }
- }
--
/*
* Set standard file descriptors to /dev/null
*/
/* Get current PID */
unsigned int
- platform_getpid()
+ platform_getpid(void)
{
+ FUZZING_BLOCK;
+
#ifdef _WIN32
return (unsigned int) GetCurrentProcessId();
#else
/* Android 4.4 workaround */
if (oldtunfd >=0 && android_method == ANDROID_OPEN_AFTER_CLOSE)
{
- close(oldtunfd);
+ platform_close(oldtunfd);
- openvpn_sleep(2);
+ management_sleep(2);
}
if (oldtunfd >=0 && android_method == ANDROID_KEEP_OLD_TUN)
if (ioctl(fd, CTLIOCGINFO, &ctlInfo) == -1)
{
- close(fd);
+ platform_close(fd);
- msg(M_INFO, "Opening utun (%s): %s", "ioctl(CTLIOCGINFO)",
- strerror(errno));
+ msg(M_INFO | M_ERRNO, "Opening utun (ioctl(CTLIOCGINFO))");
return -2;
}
if (connect(fd, (struct sockaddr *)&sc, sizeof(sc)) < 0)
{
- msg(M_INFO, "Opening utun (%s): %s", "connect(AF_SYS_CONTROL)",
- strerror(errno));
+ msg(M_INFO | M_ERRNO, "Opening utun (connect(AF_SYS_CONTROL))");
- close(fd);
+ platform_close(fd);
return -1;
}