Skip to content

Commit

Permalink
Increase length for UID to 20 (closes #444)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnErrupTion committed Dec 7, 2022
1 parent 77eb456 commit a7b01a7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/login.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ void env_xdg_session(const enum display_server display_server)

void env_xdg(const char* tty_id, const char* desktop_name)
{
char user[15];
snprintf(user, 15, "/run/user/%d", getuid());
char user[20];
snprintf(user, 20, "/run/user/%d", getuid());
setenv("XDG_RUNTIME_DIR", user, 0);
setenv("XDG_SESSION_CLASS", "user", 0);
setenv("XDG_SESSION_ID", "1", 0);
Expand Down

1 comment on commit a7b01a7

@xVermillionx
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the size of char user not be 21?

Tested using max int according to "google" the largest possible UID which has 10 positions + length of /run/user/ (10) = 20 and + 1 for the 0 terminator

char* user[21];
snprintf(user, 21, "/run/user/%d", 2147483647);
printf(user);
printf("\n");

The same code using 20 results in the 7 not being retained in user[20] and replaced by \0

Please sign in to comment.