Skip to content

Commit

Permalink
Updated to accomidate larger kernel pid sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
emptymonkey committed Apr 27, 2022
1 parent bce139f commit 8a97501
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 4 additions & 5 deletions libctty.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ void clean_pids(struct pid_node *head);
void clean_pgids(struct pgid_node *head);


// "/dev/pts/" -> 9 + MAX_INT_LEN
#define MAX_INT_LEN 10
#define MAX_PATH_LEN 19
// "/dev/pts/" -> 9 + KERN_PIDMAX
#define MAX_PATH_LEN KERN_PIDMAX + 19


/************************************************************************
Expand Down Expand Up @@ -109,7 +108,7 @@ char *ctty_get_name(int pid){
goto CLEAN_UP;
}
memset(name, 0, strlen(scratch) + 1);
strncpy(name, scratch, strlen(scratch));
strncpy(name, scratch, MAX_PATH_LEN);
goto CLEAN_UP;
}
}
Expand Down Expand Up @@ -566,7 +565,7 @@ int ctty_get_fds(int pid, char *tty, int **fds){
#endif
return(-1);
}

if(!(proc_pid_fd = opendir(path))){
#ifdef DEBUG
fprintf(stderr, "%s: ctty_get_fds(): opendir(%s): %s\n", program_invocation_short_name, \
Expand Down
4 changes: 3 additions & 1 deletion libctty.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
#include <string.h>
#include <unistd.h>

#include <sys/types.h>
#include <linux/sysctl.h>

#include <sys/stat.h>
#include <sys/types.h>


#define BUFF_LEN 1024
Expand Down

0 comments on commit 8a97501

Please sign in to comment.