diff options
author | Matthias Hopf <mhopf@suse.de> | 2010-04-06 17:08:47 +0200 |
---|---|---|
committer | Matthias Hopf <mhopf@suse.de> | 2010-04-06 17:08:47 +0200 |
commit | 2d103e1e774a4575e8fb16805e7695406f6ecd7c (patch) | |
tree | 9649a223210814eebc59fb04360a9d125b11c704 | |
parent | cde3bfb9e4b6fc779ece4d6acd3f402ef3e81778 (diff) |
Fix potential endless loop in 2 reverse engineered table dumpers.
-rw-r--r-- | atombios_rev.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/atombios_rev.h b/atombios_rev.h index db6359c..f233685 100644 --- a/atombios_rev.h +++ b/atombios_rev.h @@ -88,8 +88,11 @@ static inline char *offset_ATOM_VRAM_INFO_V3_aVramInfo(ATOM_VRAM_INFO_V3 *d, int } static inline int count_ATOM_VRAM_INFO_V3_aVramInfo(ATOM_VRAM_INFO_V3 *d) { int i=0; - while (offset_ATOM_VRAM_INFO_V3_aVramInfo(d,i)-(char*)d < d->usMemAdjustTblOffset) + char *last = 0, *next; + while ( (next = offset_ATOM_VRAM_INFO_V3_aVramInfo(d,i)) - (char*)d < d->usMemAdjustTblOffset && next != last) { + last = next; i++; + } return i; } static inline char *offset_ATOM_VOLTAGE_OBJECT_INFO_asVoltageObj(ATOM_VOLTAGE_OBJECT_INFO *d, int i) { @@ -100,8 +103,11 @@ static inline char *offset_ATOM_VOLTAGE_OBJECT_INFO_asVoltageObj(ATOM_VOLTAGE_OB } static inline int count_ATOM_VOLTAGE_OBJECT_INFO_asVoltageObj(ATOM_VOLTAGE_OBJECT_INFO *d) { int i=0; - while (offset_ATOM_VOLTAGE_OBJECT_INFO_asVoltageObj(d,i)-(char*)d < d->sHeader.usStructureSize) + char *last=0, *next; + while ( (next = offset_ATOM_VOLTAGE_OBJECT_INFO_asVoltageObj(d,i)) - (char*)d < d->sHeader.usStructureSize && next != last) { + last = next; i++; + } return i; } |