summaryrefslogtreecommitdiffstats
path: root/policy.c
diff options
context:
space:
mode:
authorNigel Croxon <ncroxon@redhat.com>2021-10-14 18:02:00 +0200
committerJes Sorensen <jsorensen@fb.com>2021-10-19 08:57:43 +0200
commit1c66260df6664a5751644cbfc6ab9dcadf1d90c1 (patch)
tree954ec236d6d48d0eddfe3acf550c3ba2d8101fbd /policy.c
parentAssemble: apply sysfs rules (diff)
downloadmdadm-1c66260df6664a5751644cbfc6ab9dcadf1d90c1.tar.xz
mdadm-1c66260df6664a5751644cbfc6ab9dcadf1d90c1.zip
Fix 2 dc stream buffer
To meet requirements of Common Criteria certification vulnerablility assessment. Static code analysis has been run and found the following Error: DC.STREAM_BUFFER (CWE-120): [#def46] mdadm-4.2: dont_call: "fscanf" assumes an arbitrarily long string, so callers must use correct precision specifiers or never use "fscanf". The change is to define a value for string %s. V2: Tighten the value in policy.c to match the limit of the metadata. Add a change to policy_save_path() to use correct precision on the fscanf call. Signed-off-by: Nigel Croxon <ncroxon@redhat.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Diffstat (limited to 'policy.c')
-rw-r--r--policy.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/policy.c b/policy.c
index 3c53bd35..eee9ef63 100644
--- a/policy.c
+++ b/policy.c
@@ -761,7 +761,7 @@ void policy_save_path(char *id_path, struct map_ent *array)
return;
}
- if (fprintf(f, "%s %08x:%08x:%08x:%08x\n",
+ if (fprintf(f, "%20s %08x:%08x:%08x:%08x\n",
array->metadata,
array->uuid[0], array->uuid[1],
array->uuid[2], array->uuid[3]) <= 0)
@@ -784,7 +784,7 @@ int policy_check_path(struct mdinfo *disk, struct map_ent *array)
if (!f)
continue;
- rv = fscanf(f, " %s %x:%x:%x:%x\n",
+ rv = fscanf(f, " %20s %x:%x:%x:%x\n",
array->metadata,
array->uuid,
array->uuid+1,