Codebase list mdadm / 1c66260
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> Nigel Croxon authored 2 years ago Jes Sorensen committed 2 years ago
2 changed file(s) with 3 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
358358 "/proc/%d/comm", pid);
359359 comm_fp = fopen(comm_path, "r");
360360 if (comm_fp) {
361 if (fscanf(comm_fp, "%s", comm) &&
361 if (fscanf(comm_fp, "%19s", comm) &&
362362 strncmp(basename(comm), Name, strlen(Name)) == 0) {
363363 if (scan) {
364364 pr_err("Only one autorebuild process allowed in scan mode, aborting\n");
760760 return;
761761 }
762762
763 if (fprintf(f, "%s %08x:%08x:%08x:%08x\n",
763 if (fprintf(f, "%20s %08x:%08x:%08x:%08x\n",
764764 array->metadata,
765765 array->uuid[0], array->uuid[1],
766766 array->uuid[2], array->uuid[3]) <= 0)
783783 if (!f)
784784 continue;
785785
786 rv = fscanf(f, " %s %x:%x:%x:%x\n",
786 rv = fscanf(f, " %20s %x:%x:%x:%x\n",
787787 array->metadata,
788788 array->uuid,
789789 array->uuid+1,