classifier: use secure versions of strcmp and strcpy
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
parent
9653b76a04
commit
eef3667435
@ -208,7 +208,7 @@ static int _cas_cls_string_ctr(struct cas_classifier *cls,
|
|||||||
if (!ctx)
|
if (!ctx)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
strcpy(ctx->string, data);
|
strncpy(ctx->string, data, MAX_STRING_SPECIFIER_LEN);
|
||||||
ctx->len = len;
|
ctx->len = len;
|
||||||
|
|
||||||
c->context = ctx;
|
c->context = ctx;
|
||||||
@ -457,6 +457,7 @@ static cas_cls_eval_t _cas_cls_extension_test(
|
|||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
struct dentry *dentry;
|
struct dentry *dentry;
|
||||||
char *extension;
|
char *extension;
|
||||||
|
uint32_t len;
|
||||||
|
|
||||||
ctx = c->context;
|
ctx = c->context;
|
||||||
inode = io->inode;
|
inode = io->inode;
|
||||||
@ -474,7 +475,9 @@ static cas_cls_eval_t _cas_cls_extension_test(
|
|||||||
return cas_cls_eval_no;
|
return cas_cls_eval_no;
|
||||||
|
|
||||||
/* First character of @extension is '.', which we don't want to compare */
|
/* First character of @extension is '.', which we don't want to compare */
|
||||||
if (strcmp(ctx->string, extension + 1) == 0)
|
len = strnlen(extension + 1, dentry->d_name.len);
|
||||||
|
len = min(ctx->len, len);
|
||||||
|
if (strncmp(ctx->string, extension + 1, len) == 0)
|
||||||
return cas_cls_eval_yes;
|
return cas_cls_eval_yes;
|
||||||
|
|
||||||
return cas_cls_eval_no;
|
return cas_cls_eval_no;
|
||||||
@ -547,12 +550,15 @@ static cas_cls_eval_t _cas_cls_process_name_test(
|
|||||||
currently executing task */
|
currently executing task */
|
||||||
struct task_struct *ti = current;
|
struct task_struct *ti = current;
|
||||||
char comm[TASK_COMM_LEN];
|
char comm[TASK_COMM_LEN];
|
||||||
|
uint32_t len;
|
||||||
|
|
||||||
ctx = c->context;
|
ctx = c->context;
|
||||||
|
|
||||||
get_task_comm(comm, ti);
|
get_task_comm(comm, ti);
|
||||||
|
|
||||||
if (strcmp(ctx->string, comm) == 0)
|
len = strnlen(comm, TASK_COMM_LEN);
|
||||||
|
len = min(ctx->len, len);
|
||||||
|
if (strncmp(ctx->string, comm, len) == 0)
|
||||||
return cas_cls_eval_yes;
|
return cas_cls_eval_yes;
|
||||||
|
|
||||||
return cas_cls_eval_no;
|
return cas_cls_eval_no;
|
||||||
|
Loading…
Reference in New Issue
Block a user