-
- for (hashIndex = 0; hashIndex < 16; hashIndex++, tempBuffer += 2) {
- sscanf(tempBuffer, "%hhx", hash + hashIndex);
+ free(sizeString);
+
+ for (hashIndex = 0; hashIndex < 16; hashIndex++) {
+ char byteBuffer[3];
+ byteBuffer[2] = '\0';
+ memcpy(byteBuffer, tempBuffer + hashIndex * 2, 2);
+ if (sscanf(byteBuffer, "%hhX", &hash[hashIndex]) != 1) {
+ GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] could not parse ‘%c%c’ into a byte.\n", __FILE__, __LINE__, *(byteBuffer), *(byteBuffer + 1));
+ return NULL;
+ }
+ GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] parsed ‘%c%c’ as %02x.\n", __FILE__, __LINE__, *(byteBuffer), *(byteBuffer + 1), hash[hashIndex]);