projects
/
u
/
mdw
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
More sensible error handling when we receive an SSH1 public key
[u/mdw/putty]
/
logging.c
diff --git
a/logging.c
b/logging.c
index
d27c727
..
5302998
100644
(file)
--- a/
logging.c
+++ b/
logging.c
@@
-35,6
+35,16
@@
void logtraffic(void *handle, unsigned char c, int logmode)
}
/*
}
/*
+ * Flush any open log file.
+ */
+void logflush(void *handle) {
+ struct LogContext *ctx = (struct LogContext *)handle;
+ if (ctx->cfg.logtype > 0)
+ if (ctx->lgfp)
+ fflush(ctx->lgfp);
+}
+
+/*
* Log an Event Log entry. Used in SSH packet logging mode; this is
* also as convenient a place as any to put the output of Event Log
* entries to stderr when a command-line tool is in verbose mode.
* Log an Event Log entry. Used in SSH packet logging mode; this is
* also as convenient a place as any to put the output of Event Log
* entries to stderr when a command-line tool is in verbose mode.
@@
-43,7
+53,7
@@
void logtraffic(void *handle, unsigned char c, int logmode)
* platforms. Platforms which don't have a meaningful stderr can
* just avoid defining FLAG_STDERR.
*/
* platforms. Platforms which don't have a meaningful stderr can
* just avoid defining FLAG_STDERR.
*/
-void log_eventlog(void *handle, char *event)
+void log_eventlog(void *handle, c
onst c
har *event)
{
struct LogContext *ctx = (struct LogContext *)handle;
if ((flags & FLAG_STDERR) && (flags & FLAG_VERBOSE)) {
{
struct LogContext *ctx = (struct LogContext *)handle;
if ((flags & FLAG_STDERR) && (flags & FLAG_VERBOSE)) {
@@
-146,7
+156,7
@@
void logfopen(void *handle)
ctx->cfg.logtype == LGTYP_DEBUG ? "raw" :
ctx->cfg.logtype == LGTYP_PACKETS ? "SSH packets" : "<ukwn>"));
/* Make sure we do not exceed the output buffer size */
ctx->cfg.logtype == LGTYP_DEBUG ? "raw" :
ctx->cfg.logtype == LGTYP_PACKETS ? "SSH packets" : "<ukwn>"));
/* Make sure we do not exceed the output buffer size */
- strncat(buf, filename_to_str(ctx->currlogfilename), 128);
+ strncat(buf, filename_to_str(
&
ctx->currlogfilename), 128);
buf[strlen(buf)] = '\0';
logevent(ctx->frontend, buf);
}
buf[strlen(buf)] = '\0';
logevent(ctx->frontend, buf);
}
@@
-163,7
+173,7
@@
void logfclose(void *handle)
void *log_init(void *frontend, Config *cfg)
{
void *log_init(void *frontend, Config *cfg)
{
- struct LogContext *ctx = s
malloc(sizeof(struct LogContext)
);
+ struct LogContext *ctx = s
new(struct LogContext
);
ctx->lgfp = NULL;
ctx->frontend = frontend;
ctx->cfg = *cfg; /* STRUCTURE COPY */
ctx->lgfp = NULL;
ctx->frontend = frontend;
ctx->cfg = *cfg; /* STRUCTURE COPY */
@@
-210,10
+220,11
@@
static void xlatlognam(Filename *dest, Filename src,
int size;
char buffer[FILENAME_MAX];
int len = sizeof(buffer)-1;
int size;
char buffer[FILENAME_MAX];
int len = sizeof(buffer)-1;
- char *d, *s;
+ char *d;
+ const char *s;
d = buffer;
d = buffer;
- s = filename_to_str(src);
+ s = filename_to_str(
&
src);
while (*s) {
/* Let (bufp, len) be the string to append. */
while (*s) {
/* Let (bufp, len) be the string to append. */
@@
-257,5
+268,5
@@
static void xlatlognam(Filename *dest, Filename src,
}
*d = '\0';
}
*d = '\0';
- *dest = filename_from_str(
s
);
+ *dest = filename_from_str(
buffer
);
}
}