Line
Link Here
|
0 |
-- skey-1.1.5-orig/put.c |
0 |
++ skey-1.1.5/put.c |
Lines 2274-2295
Link Here
|
2274 |
/* Extract 'length' bits from the char array 's' starting with bit 'start' */ |
2274 |
/* Extract 'length' bits from the char array 's' starting with bit 'start' */ |
2275 |
static unsigned int extract(char *s, int start, int length) |
2275 |
static unsigned int extract(char *s, int start, int length) |
2276 |
{ |
2276 |
{ |
2277 |
unsigned char cl; |
|
|
2278 |
unsigned char cc; |
2279 |
unsigned char cr; |
2280 |
unsigned int x; |
2277 |
unsigned int x; |
|
|
2278 |
int i; |
2281 |
|
2279 |
|
2282 |
assert(length <= 11); |
2280 |
assert(length <= 11); |
2283 |
assert(start >= 0); |
2281 |
assert(start >= 0); |
2284 |
assert(length >= 0); |
2282 |
assert(length >= 0); |
2285 |
assert(start + length <= 66); |
2283 |
assert(start + length <= 66); |
2286 |
|
2284 |
|
2287 |
cl = s[start / 8]; |
2285 |
x = 0; |
2288 |
cc = s[start / 8 + 1]; |
2286 |
for (i = start / 8; i < (start + length + 7) / 8; i++) |
2289 |
cr = s[start / 8 + 2]; |
2287 |
x = (x << 8) | (unsigned char)s[i]; |
2290 |
x = ((int)(cl << 8 | cc) << 8 | cr); |
2288 |
x >>= 7 - (start + length + 7) % 8; |
2291 |
x = x >> (24 - (length + (start % 8))); |
2289 |
x &= (1 << length) - 1; |
2292 |
x = (x & (0xffff >> (16 - length))); |
|
|
2293 |
|
2290 |
|
2294 |
return x; |
2291 |
return x; |
2295 |
} |
2292 |
} |