Fix copy into fixed size buffer warning, reported by Coverity tool:
CID 258282 (#2 of 2): Copy into fixed size buffer (STRING_OVERFLOW)9.
fixed_size_dest: You might overrun the 4096-character fixed-size string
config_mount_table[config_table_index].mount.path by copying mount_point
without checking the length.
parameter_as_source: Note: This defect has an elevated risk because the
source argument is a parameter of the current function
Also, convert config_mount_table[config_table_index].name strcpy to
strncpy.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit
4c8e4fd284b4677e5e9bab4f9e13b0866020b499)
}
}
- strcpy(config_mount_table[config_table_index].name, name);
- strcpy(config_mount_table[config_table_index].mount.path, mount_point);
+ strncpy(config_mount_table[config_table_index].name, name,
+ CONTROL_NAMELEN_MAX - 1);
+ config_mount_table[config_table_index].name[CONTROL_NAMELEN_MAX - 1] =
+ '\0';
+
+ strncpy(config_mount_table[config_table_index].mount.path, mount_point,
+ FILENAME_MAX - 1);
+ config_mount_table[config_table_index].mount.path[FILENAME_MAX - 1] =
+ '\0';
+
config_mount_table[config_table_index].mount.next = NULL;
config_table_index++;
done: