Fix improperly sized string buffers in compton pid code

pull/2/head
Timothy Pearson 10 years ago
parent f568aef38d
commit f685dc8a29

@ -110,7 +110,7 @@ void write_pid_file(pid_t pid)
char uidstr[sizeof(uid_t)*8+1];
sprintf(uidstr, "%d", getuid());
int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
filename = (char*)malloc(n*sizeof(char));
filename = (char*)malloc(n*sizeof(char)+1);
memset(filename,0,n);
strcat(filename, P_tmpdir);
strcat(filename, "/.");
@ -141,7 +141,7 @@ void delete_pid_file()
char uidstr[sizeof(uid_t)*8+1];
sprintf(uidstr, "%d", getuid());
int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
filename = (char*)malloc(n*sizeof(char));
filename = (char*)malloc(n*sizeof(char)+1);
memset(filename,0,n);
strcat(filename, P_tmpdir);
strcat(filename, "/.");

@ -241,7 +241,7 @@ Workspace::Workspace( bool restore )
char uidstr[sizeof(uid_t)*8+1];
sprintf(uidstr, "%d", getuid());
int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
filename = (char*)malloc(n*sizeof(char));
filename = (char*)malloc(n*sizeof(char)+1);
memset(filename,0,n);
strcat(filename, P_tmpdir);
strcat(filename, "/.");
@ -1090,7 +1090,7 @@ void Workspace::slotReconfigure()
char uidstr[sizeof(uid_t)*8+1];
sprintf(uidstr, "%d", getuid());
int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
filename = (char*)malloc(n*sizeof(char));
filename = (char*)malloc(n*sizeof(char)+1);
memset(filename,0,n);
strcat(filename, P_tmpdir);
strcat(filename, "/.");

Loading…
Cancel
Save