Skip to content

Commit

Permalink
Increase buffer size for reading process groups
Browse files Browse the repository at this point in the history
  • Loading branch information
skosachiov committed May 30, 2024
1 parent e3799cd commit 44e4312
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/library/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@ uid_t get_program_uid_from_pid(pid_t pid)

attr_sets_entry_t *get_gid_set_from_pid(pid_t pid)
{
char buf[128];
const int buf_size = 8192;
char buf[buf_size];
int gid = -1;
FILE *f;
attr_sets_entry_t *set = init_standalone_set(INT);
Expand All @@ -349,7 +350,7 @@ attr_sets_entry_t *get_gid_set_from_pid(pid_t pid)
f = fopen(path, "rt");
if (f) {
__fsetlocking(f, FSETLOCKING_BYCALLER);
while (fgets(buf, 128, f)) {
while (fgets(buf, buf_size, f)) {
if (memcmp(buf, "Gid:", 4) == 0) {
sscanf(buf, "Gid: %d ", &gid);
append_int_attr_set(set, gid);
Expand All @@ -359,7 +360,7 @@ attr_sets_entry_t *get_gid_set_from_pid(pid_t pid)

char *data;
int offset;
while (fgets(buf, 128, f)) {
while (fgets(buf, buf_size, f)) {
if (memcmp(buf, "Groups:", 7) == 0) {
data = buf + 7;
while (sscanf(data," %d%n", &gid,
Expand Down

0 comments on commit 44e4312

Please sign in to comment.