From: John Hodge Date: Wed, 16 May 2012 03:03:05 +0000 (+0800) Subject: Modules/IPStack - Fixed bugs in IPStack_Buffer_GetBuffer X-Git-Tag: rel0.15~611^2~103 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=d45d4025353e79b7986edbd90c21d849eb61931e;p=tpg%2Facess2.git Modules/IPStack - Fixed bugs in IPStack_Buffer_GetBuffer - Also fixed unintialised value bug in interface routes --- diff --git a/KernelLand/Modules/IPStack/buffer.c b/KernelLand/Modules/IPStack/buffer.c index b8462e60..0048420e 100644 --- a/KernelLand/Modules/IPStack/buffer.c +++ b/KernelLand/Modules/IPStack/buffer.c @@ -147,7 +147,7 @@ int IPStack_Buffer_GetBuffer(tIPStackBuffer *Buffer, int Index, size_t *Length, return -1; } - if( Index > Buffer->nSubBuffers ) + if( Index >= Buffer->nSubBuffers ) { // Appended buffers Index -= Buffer->nSubBuffers; @@ -166,11 +166,12 @@ int IPStack_Buffer_GetBuffer(tIPStackBuffer *Buffer, int Index, size_t *Length, } else { - Index = Buffer->nSubBuffers - Index; + int rv = Index + 1; + Index = Buffer->nSubBuffers - Index - 1; // Prepended buffers *DataPtr = Buffer->SubBuffers[Index].Data; *Length = Buffer->SubBuffers[Index].PreLength; - return Buffer->nSubBuffers - (Index - 1); + return rv; } } diff --git a/KernelLand/Modules/IPStack/interface.c b/KernelLand/Modules/IPStack/interface.c index 8fe0a43e..a5129a72 100644 --- a/KernelLand/Modules/IPStack/interface.c +++ b/KernelLand/Modules/IPStack/interface.c @@ -237,6 +237,7 @@ tInterface *IPStack_AddInterface(const char *Device, const char *Name) iface->Next = NULL; iface->Type = 0; // Unset type iface->Address = iface->Name + nameLen + 1; // Address + memset(&iface->Route, 0, sizeof(iface->Route)); iface->Route.Network = iface->Address + IPStack_GetAddressSize(-1); iface->Route.NextHop = iface->Route.Network + IPStack_GetAddressSize(-1);