Fix double close in thread-list and non-null terminated string in debug.linux.core

This commit is contained in:
pancake 2016-06-14 03:10:47 +02:00
parent 7ff42b590f
commit 8d9e4a7836
2 changed files with 8 additions and 2 deletions

View File

@ -108,6 +108,7 @@ static prpsinfo_t *linux_get_prpsinfo(RDebug *dbg, proc_per_process_t *proc_data
}
strncpy (p->pr_psargs, ppsargs, sizeof (p->pr_psargs));
p->pr_psargs[sizeof (p->pr_psargs)-1] = 0;
free (buffer);
free (ppsargs);
free (pfname);

View File

@ -152,10 +152,14 @@ RList *linux_thread_list (int pid, RList *list) {
#define MAXPID 99999
for (i = pid; i < MAXPID; i++) { // XXX
snprintf (cmdline, sizeof(cmdline), "/proc/%d/status", i);
if (fd != -1)
if (fd != -1) {
close (fd);
fd = -1;
}
fd = open (cmdline, O_RDONLY);
if (fd == -1) continue;
if (fd == -1) {
continue;
}
if (read (fd, cmdline, 1024)<2) {
// read error
close (fd);
@ -167,6 +171,7 @@ RList *linux_thread_list (int pid, RList *list) {
int tgid = atoi (ptr + 5);
if (tgid != pid) {
close (fd);
fd = -1;
continue;
}
if (read (fd, cmdline, sizeof(cmdline) - 1) <2) {