fix(likely): #45

This commit is contained in:
javalsai 2025-07-01 01:09:49 +02:00
parent 4b6d113bdb
commit 99e27dd0c0
Signed by: javalsai
SSH Key Fingerprint: SHA256:3G83yKhBUWVABVX/vPWH88xnK4+ptMtHkZGCRXD4Mk8

View File

@ -125,12 +125,12 @@ void moarEnv(char* user, struct session session, struct passwd* pw,
uint home_len = strlen(pw->pw_dir); uint home_len = strlen(pw->pw_dir);
for (size_t i = 0; i < config->behavior.user_source.length; i++) { for (size_t i = 0; i < config->behavior.user_source.length; i++) {
char* file2sourcepath = (char*)vec_get(&config->behavior.user_source, i); char* file2sourcepath = (char*)vec_get(&config->behavior.user_source, i);
size_t newbuf_len = home_len + strlen(file2sourcepath) + 2; size_t newbuf_len = home_len + strlen(file2sourcepath) + 2; // nullbute and slash
char* newbuf = malloc(newbuf_len); // nullbyte and slash char* newbuf = malloc(newbuf_len);
if (newbuf == NULL) continue; // can't bother if (newbuf == NULL) continue; // can't bother
memcpy(newbuf, pw->pw_dir, newbuf_len); memcpy(newbuf, pw->pw_dir, home_len);
newbuf[home_len] = '/'; // assume pw_dir doesn't start with '/' :P newbuf[home_len] = '/'; // assume pw_dir doesn't start with '/' :P
memcpy(&newbuf[home_len + 1], file2sourcepath, newbuf_len - home_len); memcpy(&newbuf[home_len + 1], file2sourcepath, newbuf_len - home_len - 1);
sourceFileTry(newbuf); sourceFileTry(newbuf);
free(newbuf); free(newbuf);