mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zdev: Harden against invalid import data
Reduce chances of unintended side-effects when importing device configuration data which might have been corrupted. Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com> Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com> Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
360e8d4156
commit
5e93b53f78
@@ -17,6 +17,7 @@
|
||||
#include "device.h"
|
||||
#include "devtype.h"
|
||||
#include "export.h"
|
||||
#include "sanitize.h"
|
||||
#include "setting.h"
|
||||
#include "subtype.h"
|
||||
|
||||
@@ -35,6 +36,8 @@ static bool header_str_to_config(const char *config_str, config_t *config)
|
||||
|
||||
if (strstr(config_str, "site")) {
|
||||
if (sscanf(config_str, "site%d", &site) == 1) {
|
||||
if (site < 0 || site >= NUM_USER_SITES)
|
||||
return false;
|
||||
import_site_id = site;
|
||||
*config = config_persistent;
|
||||
return true;
|
||||
@@ -333,6 +336,8 @@ static bool parse_setting(const char *line, char **key_ptr, char **val_ptr)
|
||||
value++;
|
||||
*key_ptr = shrink_str(copy);
|
||||
*val_ptr = unquote_str(value);
|
||||
sanitize(*key_ptr, VALID_ATTRKEY);
|
||||
sanitize(*val_ptr, VALID_ATTRVAL);
|
||||
free(copy);
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user