mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-30 17:18:21 +03:00
cov: use sscanf buffer size limits
String parsing with buffer size limit.
This commit is contained in:
parent
61a11f25a3
commit
04b407674c
@ -537,7 +537,8 @@ int unmangle_string(const char *str, const char *str_name, size_t len,
|
||||
}
|
||||
|
||||
if (str[i] == '\\' && str[i+1] == 'x') {
|
||||
if (!sscanf(&str[i+2], "%2x%s", &code, str_rest)) {
|
||||
if (!sscanf(&str[i+2], "%2x%" DM_TO_STRING(DM_NAME_LEN) "s",
|
||||
&code, str_rest)) {
|
||||
log_debug_activation("Hex encoding mismatch detected in %s \"%s\" "
|
||||
"while trying to unmangle it.", str_name, str);
|
||||
goto out;
|
||||
|
@ -2278,7 +2278,8 @@ try_partition:
|
||||
return NULL;
|
||||
|
||||
while (fgets(line, sizeof(line), fp)) {
|
||||
if (sscanf(line, "%u %u %llu %s", &line_major, &line_minor, (unsigned long long *)&line_blocks, namebuf) != 4)
|
||||
if (sscanf(line, "%u %u %llu %" DM_TO_STRING(NAME_LEN) "s",
|
||||
&line_major, &line_minor, (unsigned long long *)&line_blocks, namebuf) != 4)
|
||||
continue;
|
||||
if (line_major != major)
|
||||
continue;
|
||||
|
@ -320,7 +320,10 @@ int fs_mount_state_is_misnamed(struct cmd_context *cmd, struct logical_volume *l
|
||||
while (fgets(proc_line, sizeof(proc_line), fp)) {
|
||||
if (proc_line[0] != '/')
|
||||
continue;
|
||||
if (sscanf(proc_line, "%s %s %s", proc_devpath, proc_mntpath, proc_fstype) != 3)
|
||||
if (sscanf(proc_line, "%"
|
||||
DM_TO_STRING(PATH_MAX) "s %"
|
||||
DM_TO_STRING(PATH_MAX) "s %"
|
||||
DM_TO_STRING(PATH_MAX) "s", proc_devpath, proc_mntpath, proc_fstype) != 3)
|
||||
continue;
|
||||
if (strcmp(fstype, proc_fstype))
|
||||
continue;
|
||||
|
@ -347,7 +347,7 @@ static int _parse_line(struct dm_task *dmt, char *buffer, const char *file,
|
||||
if (!*ptr || *ptr == '#')
|
||||
return 1;
|
||||
|
||||
if (sscanf(ptr, "%llu %llu %s %n",
|
||||
if (sscanf(ptr, "%llu %llu %" DM_TO_STRING(LINE_SIZE) "s %n",
|
||||
&start, &size, ttype, &n) < 3) {
|
||||
log_error("Invalid format on line %d of table %s.", line, file);
|
||||
return 0;
|
||||
|
@ -535,7 +535,8 @@ int unmangle_string(const char *str, const char *str_name, size_t len,
|
||||
}
|
||||
|
||||
if (str[i] == '\\' && str[i+1] == 'x') {
|
||||
if (!sscanf(&str[i+2], "%2x%s", &code, str_rest)) {
|
||||
if (!sscanf(&str[i+2], "%2x%" DM_TO_STRING(DM_NAME_LEN) "s",
|
||||
&code, str_rest)) {
|
||||
log_debug_activation("Hex encoding mismatch detected in %s \"%s\" "
|
||||
"while trying to unmangle it.", str_name, str);
|
||||
goto out;
|
||||
|
Loading…
Reference in New Issue
Block a user