From ca1afde75d03e6973cc6129978cdb8efde3ead95 Mon Sep 17 00:00:00 2001 From: Zach Riggle Date: Thu, 22 Jun 2017 12:24:13 -0500 Subject: [PATCH 1/2] Fix config types for integer values Fixes Gallopsled/pwntools#988 --- pwnlib/context/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pwnlib/context/__init__.py b/pwnlib/context/__init__.py index 0f5ca157c..28326f5f9 100644 --- a/pwnlib/context/__init__.py +++ b/pwnlib/context/__init__.py @@ -1359,9 +1359,12 @@ def update_context_defaults(section): if key not in ContextType.defaults: log.warn("Unknown configuration option %r in section %r" % (key, 'context')) continue - if isinstance(ContextType.defaults[key], (str, unicode, tuple)): + + default = ContextType.defaults[key] + + if isinstance(default, (str, unicode, tuple, int, long, list, dict)): value = safeeval.expr(value) - ContextType.defaults[key] = value + ContextType.defaults[key] = type(default)(value) register_config('context', update_context_defaults) From c9922e5d0a195a85789ef0cb11288b284a159472 Mon Sep 17 00:00:00 2001 From: Zach Riggle Date: Thu, 22 Jun 2017 12:26:26 -0500 Subject: [PATCH 2/2] Add warning for unsupported configuration types --- pwnlib/context/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pwnlib/context/__init__.py b/pwnlib/context/__init__.py index 28326f5f9..cad7c1f00 100644 --- a/pwnlib/context/__init__.py +++ b/pwnlib/context/__init__.py @@ -1364,6 +1364,8 @@ def update_context_defaults(section): if isinstance(default, (str, unicode, tuple, int, long, list, dict)): value = safeeval.expr(value) + else: + log.warn("Unsupported configuration option %r in section %r" % (key, 'context')) ContextType.defaults[key] = type(default)(value)