Modules/IPStack - Fixed bugs in IPStack_Buffer_GetBuffer
authorJohn Hodge <[email protected]>
Wed, 16 May 2012 03:03:05 +0000 (11:03 +0800)
committerJohn Hodge <[email protected]>
Wed, 16 May 2012 03:03:05 +0000 (11:03 +0800)
- Also fixed unintialised value bug in interface routes

KernelLand/Modules/IPStack/buffer.c
KernelLand/Modules/IPStack/interface.c

index b8462e6..0048420 100644 (file)
@@ -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;
        }
 }
 
index 8fe0a43..a5129a7 100644 (file)
@@ -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);
        

UCC git Repository :: git.ucc.asn.au