there is no place for null termination.

you will always return a string truncated by one character.

add one more byte
This commit is contained in:
ihsinme 2022-10-02 12:33:49 +03:00 committed by GitHub
parent be59f8cf5a
commit eb7637beaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -217,7 +217,7 @@ char *get_shell_name_by_ppid(const int pid)
shell=strrchr(shell,'/');
if(shell != NULL) {
shell++;
unsigned len=strlen(shell)*sizeof(char);
unsigned len=(strlen(shell)+1)*sizeof(char);
name = realloc(name, len);
strncpy(name, shell, len);
}