int len;
snprintf(path, sizeof(path), "/proc/%u/exe", pid);
- len = readlink(path, exe, sizeof(exe));
+ len = readlink(path, exe, sizeof(path));
if (len < 0) {
PLOGE("Getting exe path");
return -1;
exit(-1);
}
- if (!pid_to_exe(getpid(),&mypath) &&
- !pid_to_exe(credentials.pid,&remotepath)) {
- if (!strncmp(mypath,remotepath,strlen(mypath)))
- caller_is_self = 1;
+ if (!pid_to_exe(getpid(),mypath) &&
+ !pid_to_exe(credentials.pid,remotepath)) {
+ if (!strncmp(mypath,remotepath,PATH_MAX)) caller_is_self = 1;
}
// if the credentials on the other side imply that
// we're not calling ourselves, we can't trust anything being sent.
int connect_daemon(int argc, char *argv[], int ppid) {
int uid = getuid();
- int ptmx;
+ int ptmx = -1;
char pts_slave[PATH_MAX];
struct sockaddr_un sun;
ret = write(fd, buf + written, bufsz - written);
if (ret == -1) return -1;
written += ret;
- } while (written < bufsz);
+ } while (written < (ssize_t)bufsz);
return 0;
}
*/
int pts_open(char *slave_name, size_t slave_name_size) {
int fdm;
- char *sn_tmp;
+ char sn_tmp[slave_name_size];
// Open master ptmx device
fdm = open("/dev/ptmx", O_RDWR);
if (fdm == -1) return -1;
// Get the slave name
- sn_tmp = ptsname(fdm);
- if (!sn_tmp) {
+ if (ptsname_r(fdm, sn_tmp, slave_name_size) != 0) {
close(fdm);
return -2;
}
}
// Flag indicating whether the sigwinch watcher should terminate.
-volatile static int closing_time = 0;
+static volatile int closing_time = 0;
/**
* Thread process. Wait for a SIGWINCH to be received, then update