Fix a potential buffer overflow in 'get_shell_name_by_ppid' (#411)

This commit is contained in:
Thibault Charbonnier 2020-11-18 22:24:56 -08:00 committed by GitHub
parent 33f7f5b593
commit cba16a2d71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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