char* sizeString;
size_t size;
int hashIndex;
- char hash[16];
+ unsigned char hash[16];
GrowingBuffer growingBuffer;
GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] trying to parse “%s”...\n", __FILE__, __LINE__, buffer);
size = atol(sizeString);
GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] parsed size “%s” into %d.\n", __FILE__, __LINE__, sizeString, size);
- for (hashIndex = 0; hashIndex < 16; hashIndex++, tempBuffer += 2) {
- sscanf(tempBuffer, "%hhx", hash + hashIndex);
+ for (hashIndex = 0; hashIndex < 16; hashIndex++) {
+ char byteBuffer[3];
+ byteBuffer[2] = '\0';
+ memcpy(byteBuffer, tempBuffer + hashIndex * 2, 2);
+ sscanf(byteBuffer, "%hhX", &hash[hashIndex]);
+ GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] parsed ‘%c%c’ as %02x.\n", __FILE__, __LINE__, *(byteBuffer), *(byteBuffer + 1), hash[hashIndex]);
}
return new ED2KLink(filename, size, hash);