correctly terminate extracted strings
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 5 Jul 2008 19:43:58 +0000 (21:43 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 5 Jul 2008 19:43:58 +0000 (21:43 +0200)
ED2KLink.cpp

index 05b8d97..47f3af8 100644 (file)
@@ -72,6 +72,7 @@ ED2KLink* ED2KLink::parseED2KLink(const char* buffer) {
        growingBuffer.write(tempBuffer, (char*) pipeIndex - tempBuffer);
        filename = (char*) malloc(growingBuffer.getLimit() + 1);
        growingBuffer.read(filename, growingBuffer.getLimit());
+       sizeString[growingBuffer.getLimit()] = '\0';
        growingBuffer.clear();
        tempBuffer = pipeIndex + 1;
 
@@ -85,6 +86,7 @@ ED2KLink* ED2KLink::parseED2KLink(const char* buffer) {
        growingBuffer.write(tempBuffer, (char*) pipeIndex - tempBuffer);
        sizeString = (char*) malloc(growingBuffer.getLimit() + 1);
        growingBuffer.read(sizeString, growingBuffer.getLimit());
+       sizeString[growingBuffer.getLimit()] = '\0';
        growingBuffer.clear();
        tempBuffer = pipeIndex + 1;