mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
1b851758bd
My experimental build with clang-cl at -Wall did show up a few things that are safe enough to fix right now. One was this list of missing includes, which was causing a lot of -Wmissing-prototype warnings, and is a real risk because it means the declarations in headers weren't being type-checked against the actual function definitions. Happily, no actual mismatches.
30 lines
626 B
C
30 lines
626 B
C
/*
|
|
* Utility function to convert a textual representation of an X11
|
|
* auth hex cookie into binary auth data.
|
|
*/
|
|
|
|
#include "putty.h"
|
|
#include "ssh.h"
|
|
|
|
void *x11_dehexify(ptrlen hexpl, int *outlen)
|
|
{
|
|
int len, i;
|
|
unsigned char *ret;
|
|
|
|
len = hexpl.len / 2;
|
|
ret = snewn(len, unsigned char);
|
|
|
|
for (i = 0; i < len; i++) {
|
|
char bytestr[3];
|
|
unsigned val = 0;
|
|
bytestr[0] = ((const char *)hexpl.ptr)[2*i];
|
|
bytestr[1] = ((const char *)hexpl.ptr)[2*i+1];
|
|
bytestr[2] = '\0';
|
|
sscanf(bytestr, "%x", &val);
|
|
ret[i] = val;
|
|
}
|
|
|
|
*outlen = len;
|
|
return ret;
|
|
}
|