Commit 6f5dbefa authored by Nick Mathewson's avatar Nick Mathewson 🏃
Browse files

Normalize space: add one between every control keyword and control clause.


svn:r3003
parent 67dc7baa
......@@ -18,9 +18,9 @@ for $fn (@ARGV) {
print "Space\@EOL:$fn:$.\n";
}
## Warn about control keywords without following space.
#if (/\s(?:if|while|for|switch)\(/) {
# print " KW(:$fn:$.\n";
#}
if (/\s(?:if|while|for|switch)\(/) {
print " KW(:$fn:$.\n";
}
## Warn about multiple empty lines.
if ($lastnil && /^$/) {
print " DoubleNL:$fn:$.\n";
......
......@@ -158,7 +158,7 @@ int replace_file(const char *from, const char *to)
#ifndef MS_WINDOWS
return rename(from,to);
#else
switch(file_status(to))
switch (file_status(to))
{
case FN_NOENT:
break;
......@@ -318,11 +318,11 @@ int set_max_file_descriptors(unsigned int required_min) {
strerror(errno));
return -1;
}
if(required_min > rlim.rlim_max) {
if (required_min > rlim.rlim_max) {
log_fn(LOG_WARN,"We need %u file descriptors available, and we're limited to %lu. Please change your ulimit.", required_min, (unsigned long int)rlim.rlim_max);
return -1;
}
if(required_min > rlim.rlim_cur) {
if (required_min > rlim.rlim_cur) {
log_fn(LOG_INFO,"Raising max file descriptors from %lu to %lu.",
(unsigned long int)rlim.rlim_cur, (unsigned long int)rlim.rlim_max);
}
......
......@@ -104,10 +104,10 @@ void smartlist_add_all(smartlist_t *sl, const smartlist_t *s2)
*/
void smartlist_remove(smartlist_t *sl, void *element) {
int i;
if(element == NULL)
if (element == NULL)
return;
for(i=0; i < sl->num_used; i++)
if(sl->list[i] == element) {
for (i=0; i < sl->num_used; i++)
if (sl->list[i] == element) {
sl->list[i] = sl->list[--sl->num_used]; /* swap with the end */
i--; /* so we process the new i'th element */
}
......@@ -117,16 +117,16 @@ void smartlist_remove(smartlist_t *sl, void *element) {
*/
int smartlist_isin(const smartlist_t *sl, void *element) {
int i;
for(i=0; i < sl->num_used; i++)
if(sl->list[i] == element)
for (i=0; i < sl->num_used; i++)
if (sl->list[i] == element)
return 1;
return 0;
}
int smartlist_string_isin(const smartlist_t *sl, const char *element) {
int i;
for(i=0; i < sl->num_used; i++)
if(strcmp((const char*)sl->list[i],element)==0)
for (i=0; i < sl->num_used; i++)
if (strcmp((const char*)sl->list[i],element)==0)
return 1;
return 0;
}
......@@ -135,8 +135,8 @@ int smartlist_string_isin(const smartlist_t *sl, const char *element) {
*/
int smartlist_overlap(const smartlist_t *sl1, const smartlist_t *sl2) {
int i;
for(i=0; i < sl2->num_used; i++)
if(smartlist_isin(sl1, sl2->list[i]))
for (i=0; i < sl2->num_used; i++)
if (smartlist_isin(sl1, sl2->list[i]))
return 1;
return 0;
}
......@@ -146,8 +146,8 @@ int smartlist_overlap(const smartlist_t *sl1, const smartlist_t *sl2) {
*/
void smartlist_intersect(smartlist_t *sl1, const smartlist_t *sl2) {
int i;
for(i=0; i < sl1->num_used; i++)
if(!smartlist_isin(sl2, sl1->list[i])) {
for (i=0; i < sl1->num_used; i++)
if (!smartlist_isin(sl2, sl1->list[i])) {
sl1->list[i] = sl1->list[--sl1->num_used]; /* swap with the end */
i--; /* so we process the new i'th element */
}
......@@ -158,7 +158,7 @@ void smartlist_intersect(smartlist_t *sl1, const smartlist_t *sl2) {
*/
void smartlist_subtract(smartlist_t *sl1, const smartlist_t *sl2) {
int i;
for(i=0; i < sl2->num_used; i++)
for (i=0; i < sl2->num_used; i++)
smartlist_remove(sl1, sl2->list[i]);
}
......@@ -544,7 +544,7 @@ void strmap_foreach(strmap_t *map,
* iter = strmap_iter_next_rmv(iter);
* free(val);
* } else {
* for(;*cp;cp++) *cp = toupper(*cp);
* for (;*cp;cp++) *cp = toupper(*cp);
* iter = strmap_iter_next(iter);
* }
* }
......
......@@ -60,7 +60,7 @@ char *smartlist_join_strings2(smartlist_t *sl, const char *join,
do { \
int var ## _sl_idx, var ## _sl_len=smartlist_len(sl); \
type var; \
for(var ## _sl_idx = 0; var ## _sl_idx < var ## _sl_len; \
for (var ## _sl_idx = 0; var ## _sl_idx < var ## _sl_len; \
++var ## _sl_idx) { \
var = smartlist_get((sl),var ## _sl_idx); \
cmd; \
......
......@@ -103,7 +103,7 @@ DH *_crypto_dh_env_get_dh(crypto_dh_env_t *dh);
*/
static INLINE int
crypto_get_rsa_padding_overhead(int padding) {
switch(padding)
switch (padding)
{
case RSA_NO_PADDING: return 0;
case RSA_PKCS1_OAEP_PADDING: return 42;
......@@ -116,7 +116,7 @@ crypto_get_rsa_padding_overhead(int padding) {
*/
static INLINE int
crypto_get_rsa_padding(int padding) {
switch(padding)
switch (padding)
{
case PK_NO_PADDING: return RSA_NO_PADDING;
case PK_PKCS1_PADDING: return RSA_PKCS1_PADDING;
......@@ -238,7 +238,7 @@ void crypto_free_pk_env(crypto_pk_env_t *env)
{
tor_assert(env);
if(--env->refs > 0)
if (--env->refs > 0)
return;
if (env->key)
......@@ -398,7 +398,7 @@ int crypto_pk_write_public_key_to_string(crypto_pk_env_t *env, char **dest, size
/* Now you can treat b as if it were a file. Just use the
* PEM_*_bio_* functions instead of the non-bio variants.
*/
if(!PEM_write_bio_RSAPublicKey(b, env->key)) {
if (!PEM_write_bio_RSAPublicKey(b, env->key)) {
crypto_log_errors(LOG_WARN, "writing public key to string");
return -1;
}
......@@ -435,7 +435,7 @@ int crypto_pk_read_public_key_from_string(crypto_pk_env_t *env, const char *src,
RSA_free(env->key);
env->key = PEM_read_bio_RSAPublicKey(b, NULL, NULL, NULL);
BIO_free(b);
if(!env->key) {
if (!env->key) {
crypto_log_errors(LOG_WARN, "reading public key from string");
return -1;
}
......@@ -1346,7 +1346,7 @@ int crypto_dh_compute_secret(crypto_dh_env_t *dh,
goto error;
secret_tmp = tor_malloc(crypto_dh_get_bytes(dh)+1);
result = DH_compute_key(secret_tmp, pubkey_bn, dh->dh);
if(result < 0) {
if (result < 0) {
log_fn(LOG_WARN,"DH_compute_key() failed.");
goto error;
}
......@@ -1368,7 +1368,7 @@ int crypto_dh_compute_secret(crypto_dh_env_t *dh,
if (pubkey_bn)
BN_free(pubkey_bn);
tor_free(secret_tmp);
if(result < 0)
if (result < 0)
return result;
else
return secret_len;
......@@ -1486,7 +1486,7 @@ int crypto_pseudo_rand_int(unsigned int max) {
* range.
*/
cutoff = UINT_MAX - (UINT_MAX%max);
while(1) {
while (1) {
crypto_pseudo_rand((unsigned char*) &val, sizeof(val));
if (val < cutoff)
return val % max;
......@@ -1498,7 +1498,7 @@ int crypto_pseudo_rand_int(unsigned int max) {
void *smartlist_choose(const smartlist_t *sl) {
size_t len;
len = smartlist_len(sl);
if(len)
if (len)
return smartlist_get(sl,crypto_pseudo_rand_int(len));
return NULL; /* no elements to choose from */
}
......
......@@ -34,7 +34,7 @@ typedef struct logfile_t {
/** Helper: map a log severity to descriptive string. */
static INLINE const char *sev_to_string(int severity) {
switch(severity) {
switch (severity) {
case LOG_DEBUG: return "debug";
case LOG_INFO: return "info";
case LOG_NOTICE: return "notice";
......@@ -136,7 +136,7 @@ static INLINE char *format_msg(char *buf, size_t buf_len,
}
r = tor_vsnprintf(buf+n,buf_len-n,format,ap);
if(r < 0) {
if (r < 0) {
n = buf_len-2;
strlcpy(buf+buf_len-TRUNCATED_STR_LEN-1, TRUNCATED_STR,
buf_len-(buf_len-TRUNCATED_STR_LEN-1));
......@@ -162,7 +162,7 @@ logv(int severity, const char *funcname, const char *format, va_list ap)
assert(format);
lf = logfiles;
while(lf) {
while (lf) {
if (severity > lf->loglevel || severity < lf->max_loglevel) {
lf = lf->next;
continue;
......@@ -188,7 +188,7 @@ logv(int severity, const char *funcname, const char *format, va_list ap)
lf = lf->next;
continue;
}
if(fputs(buf, lf->file) == EOF ||
if (fputs(buf, lf->file) == EOF ||
fflush(lf->file) == EOF) { /* error */
/* don't log the error! Blow away this log entry and continue. */
logfile_t *victim = lf;
......@@ -234,7 +234,7 @@ void _log_fn(int severity, const char *format, ...)
void close_logs()
{
logfile_t *victim;
while(logfiles) {
while (logfiles) {
victim = logfiles;
logfiles = logfiles->next;
close_log(victim);
......@@ -247,7 +247,7 @@ void close_logs()
void reset_logs()
{
logfile_t *lf = logfiles;
while(lf) {
while (lf) {
if (reset_log(lf)) {
/* error. don't log it. delete the log entry and continue. */
logfile_t *victim = lf;
......@@ -266,10 +266,10 @@ void reset_logs()
*/
static void delete_log(logfile_t *victim) {
logfile_t *tmpl;
if(victim == logfiles)
if (victim == logfiles)
logfiles = victim->next;
else {
for(tmpl = logfiles; tmpl && tmpl->next != victim; tmpl=tmpl->next) ;
for (tmpl = logfiles; tmpl && tmpl->next != victim; tmpl=tmpl->next) ;
tor_assert(tmpl);
tor_assert(tmpl->next == victim);
tmpl->next = victim->next;
......
......@@ -90,7 +90,7 @@ void _log_fn(int severity, const char *funcname, const char *format, ...)
extern const char *_log_fn_function_name;
void _log_fn(int severity, const char *format, ...);
/* We abuse the comma operator here, since we can't use the standard
* do {...} while(0) trick to wrap this macro, since the macro can't take
* do {...} while (0) trick to wrap this macro, since the macro can't take
* arguments. */
#define log_fn (_log_fn_function_name=__FUNCTION__),_log_fn
#endif
......
......@@ -36,7 +36,7 @@ extern int have_failed;
#define test_assert(expr) \
STMT_BEGIN \
if(expr) { printf("."); fflush(stdout); } else { \
if (expr) { printf("."); fflush(stdout); } else { \
have_failed = 1; \
printf("\nFile %s: line %d (%s): assertion failed: (%s)\n", \
__FILE__, \
......@@ -49,7 +49,7 @@ extern int have_failed;
#define test_eq(expr1, expr2) \
STMT_BEGIN \
long v1=(long)(expr1), v2=(long)(expr2); \
if(v1==v2) { printf("."); fflush(stdout); } else { \
if (v1==v2) { printf("."); fflush(stdout); } else { \
have_failed = 1; \
printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n"\
" (%ld != %ld)\n", \
......@@ -64,7 +64,7 @@ extern int have_failed;
#define test_neq(expr1, expr2) \
STMT_BEGIN \
long v1=(long)(expr1), v2=(long)(expr2); \
if(v1!=v2) { printf("."); fflush(stdout); } else { \
if (v1!=v2) { printf("."); fflush(stdout); } else { \
have_failed = 1; \
printf("\nFile %s: line %d (%s): Assertion failed: (%s!=%s)\n"\
" (%ld == %ld)\n", \
......@@ -79,7 +79,7 @@ extern int have_failed;
#define test_streq(expr1, expr2) \
STMT_BEGIN \
const char *v1=(expr1), *v2=(expr2); \
if(!strcmp(v1,v2)) { printf("."); fflush(stdout); } else { \
if (!strcmp(v1,v2)) { printf("."); fflush(stdout); } else { \
have_failed = 1; \
printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n"\
" (\"%s\" != \"%s\")\n", \
......@@ -94,7 +94,7 @@ extern int have_failed;
#define test_strneq(expr1, expr2) \
STMT_BEGIN \
const char *v1=(expr1), *v2=(expr2); \
if(strcmp(v1,v2)) { printf("."); fflush(stdout); } else { \
if (strcmp(v1,v2)) { printf("."); fflush(stdout); } else { \
have_failed = 1; \
printf("\nFile %s: line %d (%s): Assertion failed: (%s!=%s)\n"\
" (\"%s\" == \"%s\")\n", \
......@@ -109,7 +109,7 @@ extern int have_failed;
#define test_memeq(expr1, expr2, len) \
STMT_BEGIN \
const void *v1=(expr1), *v2=(expr2); \
if(!memcmp(v1,v2,(len))) { printf("."); fflush(stdout); } else { \
if (!memcmp(v1,v2,(len))) { printf("."); fflush(stdout); } else {\
have_failed = 1; \
printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n", \
__FILE__, \
......@@ -122,7 +122,7 @@ extern int have_failed;
#define test_memneq(expr1, expr2, len) \
STMT_BEGIN \
void *v1=(expr1), *v2=(expr2); \
if(memcmp(v1,v2,(len))) { printf("."); fflush(stdout); } else { \
if (memcmp(v1,v2,(len))) { printf("."); fflush(stdout); } else {\
have_failed = 1; \
printf("\nFile %s: line %d (%s): Assertion failed: (%s!=%s)\n", \
__FILE__, \
......
......@@ -176,7 +176,7 @@ tor_gzip_uncompress(char **out, size_t *out_len,
stream->avail_out = out_size;
while (1) {
switch(inflate(stream, Z_FINISH))
switch (inflate(stream, Z_FINISH))
{
case Z_STREAM_END:
goto done;
......
......@@ -466,7 +466,7 @@ tor_tls_write(tor_tls *tls, char *cp, size_t n)
tor_assert(tls->state == TOR_TLS_ST_OPEN);
if (n == 0)
return 0;
if(tls->wantwrite_n) {
if (tls->wantwrite_n) {
/* if WANTWRITE last time, we must use the _same_ n as before */
tor_assert(n >= tls->wantwrite_n);
log_fn(LOG_DEBUG,"resuming pending-write, (%d to flush, reusing %d)",
......
......@@ -108,7 +108,7 @@ void *tor_malloc(size_t size) {
}
result = malloc(size);
if(!result) {
if (!result) {
log_fn(LOG_ERR, "Out of memory. Dying.");
exit(1);
}
......@@ -150,7 +150,7 @@ char *tor_strdup(const char *s) {
tor_assert(s);
dup = strdup(s);
if(!dup) {
if (!dup) {
log_fn(LOG_ERR,"Out of memory. Dying.");
exit(1);
}
......@@ -221,7 +221,7 @@ int tor_strpartition(char *dest, size_t dest_len,
len_ins = strlen(insert);
len_out = len_in + (len_in/n)*len_ins;
is_even = (len_in%n) == 0;
switch(rule)
switch (rule)
{
case ALWAYS_TERMINATE:
if (!is_even) len_out += len_ins;
......@@ -236,7 +236,7 @@ int tor_strpartition(char *dest, size_t dest_len,
return -1;
destp = dest;
remaining = len_in;
while(remaining) {
while (remaining) {
strncpy(destp, s, n);
remaining -= n;
if (remaining < 0) {
......@@ -306,13 +306,13 @@ int strcmpend(const char *s1, const char *s2)
const char *eat_whitespace(const char *s) {
tor_assert(s);
while(isspace((int)*s) || *s == '#') {
while(isspace((int)*s))
while (isspace((int)*s) || *s == '#') {
while (isspace((int)*s))
s++;
if(*s == '#') { /* read to a \n or \0 */
while(*s && *s != '\n')
if (*s == '#') { /* read to a \n or \0 */
while (*s && *s != '\n')
s++;
if(!*s)
if (!*s)
return s;
}
}
......@@ -322,7 +322,7 @@ const char *eat_whitespace(const char *s) {
/** Return a pointer to the first char of s that is not a space or a tab,
* or to the terminating NUL if no such character exists. */
const char *eat_whitespace_no_nl(const char *s) {
while(*s == ' ' || *s == '\t')
while (*s == ' ' || *s == '\t')
++s;
return s;
}
......@@ -333,7 +333,7 @@ const char *eat_whitespace_no_nl(const char *s) {
const char *find_whitespace(const char *s) {
tor_assert(s);
while(*s && !isspace((int)*s) && *s != '#')
while (*s && !isspace((int)*s) && *s != '#')
s++;
return s;
......@@ -402,8 +402,8 @@ tor_parse_uint64(const char *s, int base, uint64_t min,
tor_assert(base <= 10);
r = (uint64_t)_atoi64(s);
endptr = (char*)s;
while(isspace(*endptr)) endptr++;
while(isdigit(*endptr)) endptr++;
while (isspace(*endptr)) endptr++;
while (isdigit(*endptr)) endptr++;
#else
r = (uint64_t)_strtoui64(s, &endptr, base);
#endif
......@@ -461,7 +461,7 @@ int base16_decode(char *dest, size_t destlen, const char *src, size_t srclen)
while (src<end) {
v1 = hex_decode_digit(*src);
v2 = hex_decode_digit(*(src+1));
if(v1<0||v2<0)
if (v1<0||v2<0)
return -1;
*(uint8_t*)dest = (v1<<4)|v2;
++dest;
......@@ -659,12 +659,12 @@ int write_all(int fd, const char *buf, size_t count, int isSocket) {
size_t written = 0;
int result;
while(written != count) {
while (written != count) {
if (isSocket)
result = send(fd, buf+written, count-written, 0);
else
result = write(fd, buf+written, count-written);
if(result<0)
if (result<0)
return -1;
written += result;
}
......@@ -681,12 +681,12 @@ int read_all(int fd, char *buf, size_t count, int isSocket) {
size_t numread = 0;
int result;
while(numread != count) {
while (numread != count) {
if (isSocket)
result = recv(fd, buf+numread, count-numread, 0);
else
result = read(fd, buf+numread, count-numread);
if(result<0)
if (result<0)
return -1;
else if (result == 0)
break;
......@@ -815,7 +815,7 @@ int write_bytes_to_file(const char *fname, const char *str, size_t len,
return -1;
}
result = write_all(fd, str, len, 0);
if(result < 0 || (size_t)result != len) {
if (result < 0 || (size_t)result != len) {
log(LOG_WARN, "Error writing to %s: %s", tempname, strerror(errno));
close(fd);
return -1;
......@@ -842,7 +842,7 @@ char *read_file_to_str(const char *filename, int bin) {
tor_assert(filename);
if(stat(filename, &statbuf) < 0) {
if (stat(filename, &statbuf) < 0) {
log_fn(LOG_INFO,"Could not stat %s.",filename);
return NULL;
}
......@@ -1260,7 +1260,7 @@ void start_daemon(const char *desired_cwd)
return;
start_daemon_called = 1;
if(!desired_cwd)
if (!desired_cwd)
desired_cwd = "/";
/* Don't hold the wrong FS mounted */
if (chdir(desired_cwd) < 0) {
......
......@@ -24,7 +24,7 @@
* calling assert() normally.
*/
#ifdef NDEBUG
#define tor_assert(expr) do {} while(0)
#define tor_assert(expr) do {} while (0)
#else
#define tor_assert(expr) do { \
if (!(expr)) { \
......@@ -41,7 +41,7 @@ void *tor_malloc_zero(size_t size);
void *tor_realloc(void *ptr, size_t size);
char *tor_strdup(const char *s);
char *tor_strndup(const char *s, size_t n);
#define tor_free(p) do {if(p) {free(p); (p)=NULL;}} while(0)
#define tor_free(p) do { if (p) {free(p); (p)=NULL;} } while (0)
/* String manipulation */
#define HEX_CHARACTERS "0123456789ABCDEFabcdef"
......
......@@ -175,17 +175,17 @@ int read_to_buf(int s, size_t at_most, buf_t *buf, int *reached_eof) {
if (buf_ensure_capacity(buf,buf->datalen+at_most))
return -1;
if(at_most + buf->datalen > buf->len)
if (at_most + buf->datalen > buf->len)
at_most = buf->len - buf->datalen; /* take the min of the two */
if(at_most == 0)
if (at_most == 0)
return 0; /* we shouldn't read anything */
// log_fn(LOG_DEBUG,"reading at most %d bytes.",at_most);
read_result = recv(s, buf->mem+buf->datalen, at_most, 0);
if (read_result < 0) {
int e = tor_socket_errno(s);
if(!ERRNO_IS_EAGAIN(e)) { /* it's a real error */
if (!ERRNO_IS_EAGAIN(e)) { /* it's a real error */
return -1;
}
return 0; /* would block. */
......@@ -250,13 +250,13 @@ int flush_buf(int s, buf_t *buf, size_t *buf_flushlen)
tor_assert(s>=0);
tor_assert(*buf_flushlen <= buf->datalen);
if(*buf_flushlen == 0) /* nothing to flush */
if (*buf_flushlen == 0) /* nothing to flush */
return 0;
write_result = send(s, buf->mem, *buf_flushlen, 0);
if (write_result < 0) {
int e = tor_socket_errno(s);
if(!ERRNO_IS_EAGAIN(e)) { /* it's a real error */
if (!ERRNO_IS_EAGAIN(e)) { /* it's a real error */
return -1;
}
log_fn(LOG_DEBUG,"write() would block, returning.");
......@@ -378,12 +378,12 @@ int fetch_from_buf_http(buf_t *buf,
bodylen = buf->datalen - headerlen;
log_fn(LOG_DEBUG,"headerlen %d, bodylen %d.", (int)headerlen, (int)bodylen);
if(max_headerlen <= headerlen) {
if (max_headerlen <= headerlen) {
log_fn(LOG_WARN,"headerlen %d larger than %d. Failing.", (int)headerlen,
(int)max_headerlen-1);
return -1;
}
if(max_bodylen <= bodylen) {
if (max_bodylen <= bodylen) {
log_fn(LOG_WARN,"bodylen %d larger than %d. Failing.", (int)bodylen, (int)max_bodylen-1);
return -1;
}
......@@ -400,22 +400,22 @@ int fetch_from_buf_http(buf_t *buf,
contentlen = i;
/* if content-length is malformed, then our body length is 0. fine. */
log_fn(LOG_DEBUG,"Got a contentlen of %d.",(int)contentlen);
if(bodylen < contentlen) {
if (bodylen < contentlen) {
log_fn(LOG_DEBUG,"body not all here yet.");
return 0; /* not all there yet */
}
if(bodylen > contentlen) {
if (bodylen > contentlen) {
bodylen = contentlen;
log_fn(LOG_DEBUG,"bodylen reduced to %d.",(int)bodylen);
}
}
/* all happy. copy into the appropriate places, and return 1 */
if(headers_out) {
if (headers_out) {
*headers_out = tor_malloc(headerlen+1);
memcpy(*headers_out,buf->mem,headerlen);
(*headers_out)[headerlen] = 0; /* null terminate it */
}
if(body_out) {
if (body_out) {
tor_assert(body_used);
*body_used = bodylen;
*body_out = tor_malloc(bodylen+1);
......@@ -457,18 +457,18 @@ int fetch_from_buf_socks(buf_t *buf, socks_request_t *req) {
* then log a warning to let him know that it might be unwise. */
static int have_warned_about_unsafe_socks = 0;
if(buf->datalen < 2) /* version and another byte */
if (buf->datalen < 2) /* version and another byte */
return 0;
switch(*(buf->mem)) { /* which version of socks? */
switch (*(buf->mem)) { /* which version of socks? */
case 5: /* socks5 */
if(req->socks_version != 5) { /* we need to negotiate a method */
if (req->socks_version != 5) { /* we need to negotiate a method */
unsigned char nummethods = (unsigned char)*(buf->mem+1);
tor_assert(!req->socks_version);
if(buf->datalen < 2u+nummethods)
if (buf->datalen < 2u+nummethods)
return 0;
if(!nummethods || !memchr(buf->mem+2, 0, nummethods)) {
if (!nummethods || !memchr(buf->mem+2, 0, nummethods)) {
log_fn(LOG_WARN,"socks5: offered methods don't include 'no auth'. Rejecting.");
req->replylen = 2; /* 2 bytes of response */
req->reply[0] = 5; /* socks5 reply */
......@@ -486,26 +486,26 @@ int fetch_from_buf_socks(buf_t *buf, socks_request_t *req) {
}
/* we know the method; read in the request */
log_fn(LOG_DEBUG,"socks5: checking request");
if(buf->datalen < 8) /* basic info plus >=2 for addr plus 2 for port */
if (buf->datalen < 8) /* basic info plus >=2 for addr plus 2 for port */
return 0; /* not yet */
req->command = (unsigned char) *(buf->mem+1);
if(req->command != SOCKS_COMMAND_CONNECT &&
if (req->command != SOCKS_COMMAND_CONNECT &&