X-Git-Url: https://git.pterodactylus.net/?p=ecparse.git;a=blobdiff_plain;f=ED2KLink.cpp;h=6ddcdc4b38646269e9c9da27b439430c689ac07f;hp=74a38c9aadf2d321d942270cdcba003b741bd1e1;hb=HEAD;hpb=a0eb955ae6aa166e2c54bcbdd2521d75264fd3ad diff --git a/ED2KLink.cpp b/ED2KLink.cpp index 74a38c9..6ddcdc4 100644 --- a/ED2KLink.cpp +++ b/ED2KLink.cpp @@ -25,7 +25,7 @@ ED2KLink::ED2KLink(const char* filename, const size_t size, const void* hash) { memcpy(this->hash, hash, 16); this->size = size; - link = (char*) calloc(13 + (strlen(filename) + 1) + 1 + getDigits(size) + 1 + 32 + 2, 1); + link = (char*) calloc(13 + strlen(filename) + 1 + getDigits(size) + 1 + 32 + 2 + 1, 1); sprintf(link, "ed2k://|file|%s|%u|", filename, size); for (int i = 0; i < 16; i++) { sprintf(link + strlen(link), "%02X", ((unsigned char*) hash)[i] & 0xff); @@ -56,9 +56,10 @@ ED2KLink* ED2KLink::parseED2KLink(const char* buffer) { char* pipeIndex; int stringLength; - GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] trying to parse “%s”...\n", __FILE__, __LINE__, buffer); + GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] trying to parse “%s”...\n", __FILE__, __LINE__, tempBuffer); - if (strncmp("ed2k://|file|", buffer, 13)) { + if (strncmp("ed2k://|file|", tempBuffer, 13)) { + GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] line does not start with “ed2k://|file|”!\n", __FILE__, __LINE__); return NULL; } @@ -71,7 +72,7 @@ ED2KLink* ED2KLink::parseED2KLink(const char* buffer) { stringLength = (char*) pipeIndex - tempBuffer; filename = (char*) malloc(stringLength + 1); memcpy(filename, tempBuffer, stringLength); - sizeString[stringLength] = '\0'; + filename[stringLength] = '\0'; tempBuffer = pipeIndex + 1; GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] parsed filename: “%s”.\n", __FILE__, __LINE__, filename);