Code assumes that tableIndex is never 0, while GCC cannot infer it. So include tableIndex=0 case into already handled error cases.
GCC/Mingw complains with: /home/eric/work/wine/dlls/inetmib1/main.c: In function 'mib2IfEntryQuery': /home/eric/work/wine/dlls/inetmib1/main.c:646:25: warning: array subscript 4294967295 is above array bounds of 'MIB_IFROW[1]' {aka 'struct _MIB_IFROW[1]'} [-Warray-bounds] 646 | &ifTable->table[tableIndex - 1], item, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /home/eric/work/wine/include/ipmib.h:21, from /home/eric/work/wine/include/iprtrmib.h:24, from /home/eric/work/wine/include/iphlpapi.h:25, from /home/eric/work/wine/dlls/inetmib1/main.c:30: /home/eric/work/wine/include/ifmib.h:66:15: note: while referencing 'table' 66 | MIB_IFROW table[1];
Signed-off-by: Eric Pouech eric.pouech@gmail.com
From: Eric Pouech eric.pouech@gmail.com
Code assumes that tableIndex is never 0, while GCC cannot infer it. So include tableIndex=0 case into already handled error cases.
GCC/Mingw complains with: /home/eric/work/wine/dlls/inetmib1/main.c: In function 'mib2IfEntryQuery': /home/eric/work/wine/dlls/inetmib1/main.c:646:25: warning: array subscript 4294967295 is above array bounds of 'MIB_IFROW[1]' {aka 'struct _MIB_IFROW[1]'} [-Warray-bounds] 646 | &ifTable->table[tableIndex - 1], item, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /home/eric/work/wine/include/ipmib.h:21, from /home/eric/work/wine/include/iprtrmib.h:24, from /home/eric/work/wine/include/iphlpapi.h:25, from /home/eric/work/wine/dlls/inetmib1/main.c:30: /home/eric/work/wine/include/ifmib.h:66:15: note: while referencing 'table' 66 | MIB_IFROW table[1];
Signed-off-by: Eric Pouech eric.pouech@gmail.com --- dlls/inetmib1/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/inetmib1/main.c b/dlls/inetmib1/main.c index 5d925183505..3255952850f 100644 --- a/dlls/inetmib1/main.c +++ b/dlls/inetmib1/main.c @@ -637,7 +637,7 @@ static BOOL mib2IfEntryQuery(BYTE bPduType, SnmpVarBind *pVarBind, { assert(tableIndex); assert(item); - if (tableIndex > ifTable->dwNumEntries) + if (!tableIndex || tableIndex > ifTable->dwNumEntries) *pErrorStatus = SNMP_ERRORSTATUS_NOSUCHNAME; else {
On 12/10/22 07:28, Eric Pouech wrote:
From: Eric Pouech eric.pouech@gmail.com
Code assumes that tableIndex is never 0, while GCC cannot infer it. So include tableIndex=0 case into already handled error cases.
GCC/Mingw complains with: /home/eric/work/wine/dlls/inetmib1/main.c: In function 'mib2IfEntryQuery': /home/eric/work/wine/dlls/inetmib1/main.c:646:25: warning: array subscript 4294967295 is above array bounds of 'MIB_IFROW[1]' {aka 'struct _MIB_IFROW[1]'} [-Warray-bounds] 646 | &ifTable->table[tableIndex - 1], item, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /home/eric/work/wine/include/ipmib.h:21, from /home/eric/work/wine/include/iprtrmib.h:24, from /home/eric/work/wine/include/iphlpapi.h:25, from /home/eric/work/wine/dlls/inetmib1/main.c:30: /home/eric/work/wine/include/ifmib.h:66:15: note: while referencing 'table' 66 | MIB_IFROW table[1];
Signed-off-by: Eric Pouech eric.pouech@gmail.com
dlls/inetmib1/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/inetmib1/main.c b/dlls/inetmib1/main.c index 5d925183505..3255952850f 100644 --- a/dlls/inetmib1/main.c +++ b/dlls/inetmib1/main.c @@ -637,7 +637,7 @@ static BOOL mib2IfEntryQuery(BYTE bPduType, SnmpVarBind *pVarBind, { assert(tableIndex); assert(item);
if (tableIndex > ifTable->dwNumEntries)
if (!tableIndex || tableIndex > ifTable->dwNumEntries) *pErrorStatus = SNMP_ERRORSTATUS_NOSUCHNAME; else {
This looks just wrong. If there's really no better way to deal with this then we should at least include a comment so someone doesn't waste time trying to "fix" this.
This merge request was closed by eric pouech.