mirror of
https://github.com/javalsai/lidm.git
synced 2025-07-03 14:25:03 +02:00
fix: strlcpy usage & changes
This commit is contained in:
parent
002788c693
commit
8403bfc26c
@ -125,12 +125,10 @@ void moarEnv(char* user, struct session session, struct passwd* pw,
|
|||||||
size_t newbuf_len = home_len + strlen(file2sourcepath) + 2;
|
size_t newbuf_len = home_len + strlen(file2sourcepath) + 2;
|
||||||
char* newbuf = malloc(newbuf_len); // nullbyte and slash
|
char* newbuf = malloc(newbuf_len); // nullbyte and slash
|
||||||
if (newbuf == NULL) continue; // can't bother
|
if (newbuf == NULL) continue; // can't bother
|
||||||
strlcpy(newbuf, pw->pw_dir, newbuf_len);
|
memcpy(newbuf, pw->pw_dir, newbuf_len);
|
||||||
newbuf[home_len] = '/'; // assume pw_dir doesn't start with '/' :P
|
newbuf[home_len] = '/'; // assume pw_dir doesn't start with '/' :P
|
||||||
strlcpy(&newbuf[home_len + 1], file2sourcepath,
|
memcpy(&newbuf[home_len + 1], file2sourcepath, newbuf_len - home_len);
|
||||||
newbuf_len - home_len - 1);
|
|
||||||
|
|
||||||
/* printf("DEBUG(user_source)!!!! %d %s\n", i, newbuf); */
|
|
||||||
sourceFileTry(newbuf);
|
sourceFileTry(newbuf);
|
||||||
free(newbuf);
|
free(newbuf);
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ struct parser_error parse_key(enum introspection_type typ, union typ_ptr at,
|
|||||||
aux_str = strdup(key);
|
aux_str = strdup(key);
|
||||||
if (!aux_str) FAIL("allocation failure");
|
if (!aux_str) FAIL("allocation failure");
|
||||||
aux_err = parse_str_inplace(aux_str);
|
aux_err = parse_str_inplace(aux_str);
|
||||||
if (aux_err.msg != NULL) {
|
if (!aux_err.msg) {
|
||||||
free(aux_str);
|
free(aux_str);
|
||||||
return aux_err;
|
return aux_err;
|
||||||
}
|
}
|
||||||
@ -157,7 +157,7 @@ struct parser_error parse_key(enum introspection_type typ, union typ_ptr at,
|
|||||||
aux_str = strdup(key);
|
aux_str = strdup(key);
|
||||||
if (!aux_str) FAIL("allocation failure");
|
if (!aux_str) FAIL("allocation failure");
|
||||||
aux_err = parse_str_inplace(aux_str);
|
aux_err = parse_str_inplace(aux_str);
|
||||||
if (aux_err.msg != NULL) {
|
if (!aux_err.msg) {
|
||||||
free(aux_str);
|
free(aux_str);
|
||||||
return aux_err;
|
return aux_err;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user