mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Improve treatment of signature components
This commit is contained in:
@@ -98,7 +98,7 @@ public:
|
|||||||
: m_skip (0)
|
: m_skip (0)
|
||||||
{
|
{
|
||||||
// The format is: <02> <length of signature> <signature>
|
// The format is: <02> <length of signature> <signature>
|
||||||
if ((sig[0] != 0x02) || (size < 3))
|
if ((size < 3) || (sig[0] != 0x02))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::size_t const len (sig[1]);
|
std::size_t const len (sig[1]);
|
||||||
|
|||||||
@@ -271,12 +271,13 @@ unsigned long RFC1751::extract (char const* s, int start, int length)
|
|||||||
assert (length >= 0);
|
assert (length >= 0);
|
||||||
assert (start + length <= 66);
|
assert (start + length <= 66);
|
||||||
|
|
||||||
|
int const shiftR = 24 - (length + (start % 8));
|
||||||
cl = s[start / 8]; // get components
|
cl = s[start / 8]; // get components
|
||||||
cc = s[start / 8 + 1];
|
cc = (shiftR < 16) ? s[start / 8 + 1] : 0;
|
||||||
cr = s[start / 8 + 2];
|
cr = (shiftR < 8) ? s[start / 8 + 2] : 0;
|
||||||
|
|
||||||
x = ((long) (cl << 8 | cc) << 8 | cr) ; // Put bits together
|
x = ((long) (cl << 8 | cc) << 8 | cr) ; // Put bits together
|
||||||
x = x >> (24 - (length + (start % 8))); // Right justify number
|
x = x >> shiftR; // Right justify number
|
||||||
x = ( x & (0xffff >> (16 - length) ) ); // Trim extra bits.
|
x = ( x & (0xffff >> (16 - length) ) ); // Trim extra bits.
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
|
|||||||
Reference in New Issue
Block a user