Skip to content

Commit 528b119

Browse files
committed
auditctl: validate list and delete keys
1 parent 52d5252 commit 528b119

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/auditctl.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ enum {
6464
/* Global functions */
6565
static int handle_request(int status);
6666
static void get_reply(void);
67+
static int process_key_option(const char *optarg, char *key,
68+
unsigned int *keylen);
6769
extern int delete_all_rules(int fd);
6870

6971
/* Global vars */
@@ -785,8 +787,12 @@ static int opt_list(opt_handler_params_t *args)
785787
return OPT_ERROR_NO_REPLY;
786788
}
787789
} else if (*(args->count) == 4) {
790+
int rc;
791+
788792
if (args->vars[optind] && strcmp(args->vars[optind], "-k") == 0) {
789-
strncat(key, args->vars[3], keylen);
793+
rc = process_key_option(args->vars[3], key, &keylen);
794+
if (rc)
795+
return rc;
790796
*(args->count) -= 2;
791797
} else {
792798
audit_msg(LOG_ERR,
@@ -1118,8 +1124,12 @@ static int opt_delete_all(opt_handler_params_t *args)
11181124
return OPT_ERROR_NO_REPLY;
11191125
}
11201126
if (*(args->count) == 4) {
1127+
int rc;
1128+
11211129
if (strcmp(args->vars[optind], "-k") == 0) {
1122-
strncat(key, args->vars[3], keylen);
1130+
rc = process_key_option(args->vars[3], key, &keylen);
1131+
if (rc)
1132+
return rc;
11231133
*(args->count) -= 2;
11241134
} else {
11251135
audit_msg(LOG_ERR,

0 commit comments

Comments
 (0)