skill: Fix getline() usage.
man getline: "If *lineptr is set to NULL and *n is set 0 before the call, then getline() will allocate a buffer for storing the line. This buffer should be freed by the user program even if getline() failed."
This commit is contained in:
parent
7d6977b6f7
commit
453e1df5d1
6
skill.c
6
skill.c
@ -131,13 +131,15 @@ static void hurt_proc(int tty, int uid, int pid, const char *restrict const cmd,
|
|||||||
char dn_buf[1000];
|
char dn_buf[1000];
|
||||||
dev_to_tty(dn_buf, 999, tty, pid, ABBREV_DEV);
|
dev_to_tty(dn_buf, 999, tty, pid, ABBREV_DEV);
|
||||||
if (run_time->interactive) {
|
if (run_time->interactive) {
|
||||||
char *buf;
|
char *buf = NULL;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
fprintf(stderr, "%-8s %-8s %5d %-16.16s ? ",
|
fprintf(stderr, "%-8s %-8s %5d %-16.16s ? ",
|
||||||
(char *)dn_buf, pwcache_get_user(uid), pid, cmd);
|
(char *)dn_buf, pwcache_get_user(uid), pid, cmd);
|
||||||
fflush (stdout);
|
fflush (stdout);
|
||||||
if (getline(&buf, &len, stdin) == -1)
|
if (getline(&buf, &len, stdin) == -1) {
|
||||||
|
free(buf);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (rpmatch(buf) < 1) {
|
if (rpmatch(buf) < 1) {
|
||||||
free(buf);
|
free(buf);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user