Take transmit and receive keys into use separately

This commit is contained in:
Matt Johnston
2013-04-04 00:18:50 +08:00
parent e2c813df4d
commit 7f42096d0f
6 changed files with 64 additions and 54 deletions

View File

@@ -138,29 +138,39 @@ void dropbear_log(int priority, const char* format, ...) {
#ifdef DEBUG_TRACE
void dropbear_trace(const char* format, ...) {
va_list param;
struct timeval tv;
if (!debug_trace) {
return;
}
gettimeofday(&tv, NULL);
va_start(param, format);
fprintf(stderr, "TRACE (%d): ", getpid());
fprintf(stderr, "TRACE (%d) %d.%d: ", getpid(), tv.tv_sec, tv.tv_usec);
vfprintf(stderr, format, param);
fprintf(stderr, "\n");
va_end(param);
}
void dropbear_trace2(const char* format, ...) {
static int trace_env = -1;
va_list param;
struct timeval tv;
if (!(debug_trace && getenv("DROPBEAR_TRACE2"))) {
if (trace_env == -1) {
trace_env = getenv("DROPBEAR_TRACE2") ? 1 : 0;
}
if (!(debug_trace && trace_env)) {
return;
}
gettimeofday(&tv, NULL);
va_start(param, format);
fprintf(stderr, "TRACE2 (%d): ", getpid());
fprintf(stderr, "TRACE2 (%d) %d.%d: ", getpid(), tv.tv_sec, tv.tv_usec);
vfprintf(stderr, format, param);
fprintf(stderr, "\n");
va_end(param);
@@ -739,8 +749,6 @@ int buf_getline(buffer * line, FILE * authfile) {
int c = EOF;
TRACE2(("enter buf_getline"))
buf_setpos(line, 0);
buf_setlen(line, 0);
@@ -764,10 +772,8 @@ out:
/* if we didn't read anything before EOF or error, exit */
if (c == EOF && line->pos == 0) {
TRACE2(("leave buf_getline: failure"))
return DROPBEAR_FAILURE;
} else {
TRACE2(("leave buf_getline: success"))
buf_setpos(line, 0);
return DROPBEAR_SUCCESS;
}