Run indentation script.

git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1658 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
Henrik Andersson 2012-01-16 06:35:13 +00:00
parent 4dc2ce1a6a
commit cdce9aae75
5 changed files with 42 additions and 43 deletions

View File

@ -69,7 +69,7 @@ licence_present(uint8 * client_random, uint8 * rsa_data,
s = sec_init(sec_flags, length + 2);
out_uint8(s, LICENCE_TAG_PRESENT);
out_uint8(s, (g_use_rdp5? 3 : 2)); /* version */
out_uint8(s, (g_use_rdp5 ? 3 : 2)); /* version */
out_uint16_le(s, length);
out_uint32_le(s, 1);
@ -103,15 +103,14 @@ licence_send_request(uint8 * client_random, uint8 * rsa_data, char *user, char *
uint32 sec_flags = SEC_LICENCE_NEG;
uint16 userlen = strlen(user) + 1;
uint16 hostlen = strlen(host) + 1;
uint16 length =
24 + SEC_RANDOM_SIZE + SEC_MODULUS_SIZE + SEC_PADDING_SIZE +
userlen + hostlen;
uint16 length =
24 + SEC_RANDOM_SIZE + SEC_MODULUS_SIZE + SEC_PADDING_SIZE + userlen + hostlen;
STREAM s;
s = sec_init(sec_flags, length + 2);
out_uint8(s, LICENCE_TAG_REQUEST);
out_uint8(s, (g_use_rdp5? 3 : 2)); /* version */
out_uint8(s, (g_use_rdp5 ? 3 : 2)); /* version */
out_uint16_le(s, length);
out_uint32_le(s, 1);
@ -193,7 +192,7 @@ licence_send_authresp(uint8 * token, uint8 * crypt_hwid, uint8 * signature)
s = sec_init(sec_flags, length + 2);
out_uint8(s, LICENCE_TAG_AUTHRESP);
out_uint8(s, (g_use_rdp5? 3 : 2)); /* version */
out_uint8(s, (g_use_rdp5 ? 3 : 2)); /* version */
out_uint16_le(s, length);
out_uint16_le(s, 1);

View File

@ -176,8 +176,8 @@ void rdpsnd_queue_next(unsigned long completed_in_us);
int rdpsnd_queue_next_tick(void);
void rdpsnd_reset_state(void);
/* secure.c */
void sec_hash_to_string(char * out, int out_size, uint8 * in, int in_size);
void sec_hash_sha1_16(uint8 * out, uint8 * in, uint8 *salt1);
void sec_hash_to_string(char *out, int out_size, uint8 * in, int in_size);
void sec_hash_sha1_16(uint8 * out, uint8 * in, uint8 * salt1);
void sec_hash_48(uint8 * out, uint8 * in, uint8 * salt1, uint8 * salt2, uint8 salt);
void sec_hash_16(uint8 * out, uint8 * in, uint8 * salt1, uint8 * salt2);
void buf_out_uint32(uint8 * buffer, uint32 value);

View File

@ -53,7 +53,7 @@
#define RDESKTOP_LICENSE_STORE "/.local/share/rdesktop/licenses"
uint8 g_static_rdesktop_salt_16[16] = {
0xb8, 0x82, 0x29, 0x31, 0xc5, 0x39, 0xd9, 0x44,
0xb8, 0x82, 0x29, 0x31, 0xc5, 0x39, 0xd9, 0x44,
0x54, 0x15, 0x5e, 0x14, 0x71, 0x38, 0xd5, 0x4d
};
@ -1501,14 +1501,14 @@ l_to_a(long N, int base)
return ret;
}
static int
static int
safe_mkdir(const char *path, int mask)
{
int res = 0;
struct stat st;
res = stat(path, &st);
if (res == -1 )
if (res == -1)
return mkdir(path, mask);
if (!S_ISDIR(st.st_mode))
@ -1520,7 +1520,7 @@ safe_mkdir(const char *path, int mask)
return 0;
}
static int
static int
mkdir_p(const char *path, int mask)
{
int res;
@ -1538,27 +1538,28 @@ mkdir_p(const char *path, int mask)
errno = E2BIG;
return -1;
}
res = 0;
res = 0;
pt[0] = bp[0] = '\0';
strcpy(bp, path);
ptok = strtok(bp, "/");
if (ptok == NULL)
return safe_mkdir(path,mask);
return safe_mkdir(path, mask);
do
{
if (ptok != bp)
strcat(pt, "/");
strcat(pt, ptok);
strcat(pt, ptok);
res = safe_mkdir(pt, mask);
if (res != 0)
return res;
} while ((ptok = strtok(NULL, "/")) != NULL);
}
while ((ptok = strtok(NULL, "/")) != NULL);
return 0;
}
@ -1574,21 +1575,19 @@ load_licence(unsigned char **data)
if (home == NULL)
return -1;
snprintf((char*)hi, 16, g_hostname);
snprintf((char *) hi, 16, g_hostname);
sec_hash_sha1_16(ho, hi, g_static_rdesktop_salt_16);
sec_hash_to_string(hash, 40, ho, 22);
snprintf(path, PATH_MAX, "%s"RDESKTOP_LICENSE_STORE"/%s.cal",
home, hash);
path[sizeof(path)-1] = '\0';
snprintf(path, PATH_MAX, "%s" RDESKTOP_LICENSE_STORE "/%s.cal", home, hash);
path[sizeof(path) - 1] = '\0';
fd = open(path, O_RDONLY);
if (fd == -1)
{
/* fallback to try reading old license file */
snprintf(path, PATH_MAX, "%s/.rdesktop/license.%s",
home, g_hostname);
path[sizeof(path)-1] = '\0';
snprintf(path, PATH_MAX, "%s/.rdesktop/license.%s", home, g_hostname);
path[sizeof(path) - 1] = '\0';
if ((fd = open(path, O_RDONLY)) == -1)
return -1;
}
@ -1616,26 +1615,25 @@ save_licence(unsigned char *data, int length)
if (home == NULL)
return;
snprintf(path, PATH_MAX, "%s"RDESKTOP_LICENSE_STORE, home);
path[sizeof(path)-1] = '\0';
if ( mkdir_p(path, 0700) == -1)
snprintf(path, PATH_MAX, "%s" RDESKTOP_LICENSE_STORE, home);
path[sizeof(path) - 1] = '\0';
if (mkdir_p(path, 0700) == -1)
{
perror(path);
return;
}
snprintf((char*)hi,16,g_hostname);
snprintf((char *) hi, 16, g_hostname);
sec_hash_sha1_16(ho, hi, g_static_rdesktop_salt_16);
sec_hash_to_string(hash, 40, ho, 20);
/* write licence to {sha1}.cal.new, then atomically
rename to {sha1}.cal */
snprintf(path, PATH_MAX, "%s"RDESKTOP_LICENSE_STORE"/%s.cal",
home, hash);
path[sizeof(path)-1] = '\0';
snprintf(path, PATH_MAX, "%s" RDESKTOP_LICENSE_STORE "/%s.cal", home, hash);
path[sizeof(path) - 1] = '\0';
snprintf(tmppath, PATH_MAX, "%s.new", path);
path[sizeof(path)-1] = '\0';
path[sizeof(path) - 1] = '\0';
fd = open(tmppath, O_WRONLY | O_CREAT | O_TRUNC, 0600);
if (fd == -1)

View File

@ -114,7 +114,8 @@ sec_hash_16(uint8 * out, uint8 * in, uint8 * salt1, uint8 * salt2)
/*
* 16-byte sha1 hash
*/
void sec_hash_sha1_16(uint8 * out, uint8 * in, uint8 *salt1)
void
sec_hash_sha1_16(uint8 * out, uint8 * in, uint8 * salt1)
{
SSL_SHA1 sha1;
ssl_sha1_init(&sha1);
@ -124,14 +125,15 @@ void sec_hash_sha1_16(uint8 * out, uint8 * in, uint8 *salt1)
}
/* create string from hash */
void sec_hash_to_string(char * out, int out_size, uint8 * in, int in_size)
void
sec_hash_to_string(char *out, int out_size, uint8 * in, int in_size)
{
int k;
memset(out,0,out_size);
for (k=0;k<in_size;k++,out+=2)
memset(out, 0, out_size);
for (k = 0; k < in_size; k++, out += 2)
{
sprintf(out,"%.2x",in[k]);
}
sprintf(out, "%.2x", in[k]);
}
}
/* Reduce key entropy from 64 to 40 bits */

View File

@ -389,7 +389,7 @@ xclip_send_data_with_convert(uint8 * source, size_t source_size, Atom target)
translated_data = lf2crlf(source, &length);
if (translated_data != NULL)
{
helper_cliprdr_send_response(translated_data, length+1);
helper_cliprdr_send_response(translated_data, length + 1);
xfree(translated_data); /* Not the same thing as XFree! */
}