summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authornima <nima@abc39116-655e-4be6-ad55-d661dc543056>2008-12-20 15:49:18 +0000
committernima <nima@abc39116-655e-4be6-ad55-d661dc543056>2008-12-20 15:49:18 +0000
commitfe4e406114752c7d61280f32b4af84cdc2504b4d (patch)
tree06d7fc358e91da769139514c59a04da27f76d8e5 /src
parent0e2598266442b8f1015c75833034ac0f26857820 (diff)
downloadpython-dmidecode-fe4e406114752c7d61280f32b4af84cdc2504b4d.tar.gz
python-dmidecode-fe4e406114752c7d61280f32b4af84cdc2504b4d.tar.xz
python-dmidecode-fe4e406114752c7d61280f32b4af84cdc2504b4d.zip
Handle cases where user asks for invalid types.
Updated test cases to test for this too. git-svn-id: svn://svn.autonomy.net.au/python-dmidecode@136 abc39116-655e-4be6-ad55-d661dc543056
Diffstat (limited to 'src')
-rw-r--r--src/dmidecodemodule.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/dmidecodemodule.c b/src/dmidecodemodule.c
index 03001a8..3030b97 100644
--- a/src/dmidecodemodule.c
+++ b/src/dmidecodemodule.c
@@ -192,9 +192,12 @@ static PyObject* dmidecode_get_slot(PyObject *self, PyObject *args) { retur
static PyObject* dmidecode_get_type(PyObject *self, PyObject *args) {
long unsigned int lu;
if(PyArg_ParseTuple(args, (char *)"i", &lu)) {
- char s[8];
- sprintf(s, "%lu", lu);
- return dmidecode_get(self, s);
+ if(lu < 256) {
+ char s[8];
+ sprintf(s, "%lu", lu);
+ return dmidecode_get(self, s);
+ }
+ return Py_False;
}
return Py_None;
}