projects
/
ecparse.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
dc3a8cc
)
recognize faulty hash
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Sat, 5 Jul 2008 19:07:09 +0000
(21:07 +0200)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Sat, 5 Jul 2008 19:07:09 +0000
(21:07 +0200)
ED2KLink.cpp
patch
|
blob
|
history
diff --git
a/ED2KLink.cpp
b/ED2KLink.cpp
index
e1ec2ff
..
05b8d97
100644
(file)
--- a/
ED2KLink.cpp
+++ b/
ED2KLink.cpp
@@
-96,7
+96,10
@@
ED2KLink* ED2KLink::parseED2KLink(const char* buffer) {
char byteBuffer[3];
byteBuffer[2] = '\0';
memcpy(byteBuffer, tempBuffer + hashIndex * 2, 2);
char byteBuffer[3];
byteBuffer[2] = '\0';
memcpy(byteBuffer, tempBuffer + hashIndex * 2, 2);
- sscanf(byteBuffer, "%hhX", &hash[hashIndex]);
+ 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]);
}
GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] parsed ‘%c%c’ as %02x.\n", __FILE__, __LINE__, *(byteBuffer), *(byteBuffer + 1), hash[hashIndex]);
}