mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +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 (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\" "
|
log_debug_activation("Hex encoding mismatch detected in %s \"%s\" "
|
||||||
"while trying to unmangle it.", str_name, str);
|
"while trying to unmangle it.", str_name, str);
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -2278,7 +2278,8 @@ try_partition:
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
while (fgets(line, sizeof(line), fp)) {
|
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;
|
continue;
|
||||||
if (line_major != major)
|
if (line_major != major)
|
||||||
continue;
|
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)) {
|
while (fgets(proc_line, sizeof(proc_line), fp)) {
|
||||||
if (proc_line[0] != '/')
|
if (proc_line[0] != '/')
|
||||||
continue;
|
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;
|
continue;
|
||||||
if (strcmp(fstype, proc_fstype))
|
if (strcmp(fstype, proc_fstype))
|
||||||
continue;
|
continue;
|
||||||
|
@ -347,7 +347,7 @@ static int _parse_line(struct dm_task *dmt, char *buffer, const char *file,
|
|||||||
if (!*ptr || *ptr == '#')
|
if (!*ptr || *ptr == '#')
|
||||||
return 1;
|
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) {
|
&start, &size, ttype, &n) < 3) {
|
||||||
log_error("Invalid format on line %d of table %s.", line, file);
|
log_error("Invalid format on line %d of table %s.", line, file);
|
||||||
return 0;
|
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 (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\" "
|
log_debug_activation("Hex encoding mismatch detected in %s \"%s\" "
|
||||||
"while trying to unmangle it.", str_name, str);
|
"while trying to unmangle it.", str_name, str);
|
||||||
goto out;
|
goto out;
|
||||||
|
Loading…
Reference in New Issue
Block a user