diff options
author | Darren Tucker <dtucker@cvs.openbsd.org> | 2004-12-06 11:41:04 +0000 |
---|---|---|
committer | Darren Tucker <dtucker@cvs.openbsd.org> | 2004-12-06 11:41:04 +0000 |
commit | 3fbb045d089ed1e6d9a2fcffac0aac24ca84f009 (patch) | |
tree | 6f083944d7e00f7467c3b5a669299b5dbaf64771 /usr.bin/ssh/misc.c | |
parent | 7ce9c17f546a39e1642eb072fa6a68b4cd59eda2 (diff) |
Discard over-length authorized_keys entries rather than complaining when
they don't decode. bz #884, with & ok djm@
Diffstat (limited to 'usr.bin/ssh/misc.c')
-rw-r--r-- | usr.bin/ssh/misc.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/usr.bin/ssh/misc.c b/usr.bin/ssh/misc.c index 26f62b6c16c..d659eaa9b40 100644 --- a/usr.bin/ssh/misc.c +++ b/usr.bin/ssh/misc.c @@ -23,7 +23,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: misc.c,v 1.25 2004/08/11 21:43:05 avsm Exp $"); +RCSID("$OpenBSD: misc.c,v 1.26 2004/12/06 11:41:03 dtucker Exp $"); #include "misc.h" #include "log.h" @@ -326,3 +326,26 @@ addargs(arglist *args, char *fmt, ...) args->list[args->num++] = xstrdup(buf); args->list[args->num] = NULL; } + +/* + * Read an entire line from a public key file into a static buffer, discarding + * lines that exceed the buffer size. Returns 0 on success, -1 on failure. + */ +int +read_keyfile_line(FILE *f, const char *filename, char *buf, size_t bufsz, + int *lineno) +{ + while (fgets(buf, bufsz, f) != NULL) { + (*lineno)++; + if (buf[strlen(buf) - 1] == '\n' || feof(f)) { + return 0; + } else { + debug("%s: %s line %d exceeds size limit", __func__, + filename, lineno); + /* discard remainder of line */ + while(fgetc(f) != '\n' && !feof(f)) + ; /* nothing */ + } + } + return -1; +} |