diff options
author | root <root@abc39116-655e-4be6-ad55-d661dc543056> | 2008-07-25 01:11:39 +0000 |
---|---|---|
committer | root <root@abc39116-655e-4be6-ad55-d661dc543056> | 2008-07-25 01:11:39 +0000 |
commit | b163757a47d525019cebae8e1ecb843a49a14196 (patch) | |
tree | afa580163c0c66401fe5e0db80ea61dfa8182ede /catsprintf.c | |
parent | 9483c94352b0182580972e7cac2ba585022398d5 (diff) | |
download | python-dmidecode-b163757a47d525019cebae8e1ecb843a49a14196.tar.gz python-dmidecode-b163757a47d525019cebae8e1ecb843a49a14196.tar.xz python-dmidecode-b163757a47d525019cebae8e1ecb843a49a14196.zip |
This was the culprit causing the `Abort' crash, valgrind showed that this file
is where the error lied. Stephen Darragh discovered this, and the fix has been
to use vsnprintf() and not vsprintf(), which should have been the case to begin
with really.
git-svn-id: svn://svn.autonomy.net.au/python-dmidecode@18 abc39116-655e-4be6-ad55-d661dc543056
Diffstat (limited to 'catsprintf.c')
-rw-r--r-- | catsprintf.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/catsprintf.c b/catsprintf.c index d9d73ff..c8f74fc 100644 --- a/catsprintf.c +++ b/catsprintf.c @@ -59,20 +59,26 @@ dmi_minor* dmiAppendObject(long code, char const *key, const char *format, ...) //. int minor = code&0x00FF; //. int major = code>>8; + va_list arg; va_start(arg, format); dmi_minor *o = (dmi_minor *)malloc(sizeof(dmi_minor)); + o->next = last; o->id = code; o->major = (dmi_codes_major *)&dmiCodesMajor[map_maj[code>>8]]; o->key = (char *)key; - if (format != NULL) - vsprintf(o->value, format, arg); - o->next = last; + if(format != NULL) + if(vsnprintf(o->value, MAXVAL-1, format, arg) > MAXVAL) { + free(o); + o = NULL; + //. TODO: Make this a python exception. + printf("dmidecode: Internal (python module) error; Value too long.\n"); + } - va_end(arg); /* cleanup */ last = o; + va_end(arg); /* cleanup */ return o; } |