summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2004-12-06 22:47:41 +1100
committerDarren Tucker <dtucker@zip.com.au>2004-12-06 22:47:41 +1100
commit22cc741096c85ff211dfc4c910fd28ec4858ba83 (patch)
tree312742d9b3a62da80833cb224d1df1778b2104cd /misc.c
parent16e254d17934437a811e0019107ad53cdea8eb76 (diff)
- dtucker@cvs.openbsd.org 2004/12/06 11:41:03
[auth-rsa.c auth2-pubkey.c authfile.c misc.c misc.h ssh.h sshd.8] Discard over-length authorized_keys entries rather than complaining when they don't decode. bz #884, with & ok djm@
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/misc.c b/misc.c
index 8cb411ccc..d0cc53823 100644
--- a/misc.c
+++ b/misc.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: misc.c,v 1.25 2004/08/11 21:43:05 avsm Exp $"); 26RCSID("$OpenBSD: misc.c,v 1.26 2004/12/06 11:41:03 dtucker Exp $");
27 27
28#include "misc.h" 28#include "misc.h"
29#include "log.h" 29#include "log.h"
@@ -332,3 +332,26 @@ addargs(arglist *args, char *fmt, ...)
332 args->list[args->num++] = xstrdup(buf); 332 args->list[args->num++] = xstrdup(buf);
333 args->list[args->num] = NULL; 333 args->list[args->num] = NULL;
334} 334}
335
336/*
337 * Read an entire line from a public key file into a static buffer, discarding
338 * lines that exceed the buffer size. Returns 0 on success, -1 on failure.
339 */
340int
341read_keyfile_line(FILE *f, const char *filename, char *buf, size_t bufsz,
342 int *lineno)
343{
344 while (fgets(buf, bufsz, f) != NULL) {
345 (*lineno)++;
346 if (buf[strlen(buf) - 1] == '\n' || feof(f)) {
347 return 0;
348 } else {
349 debug("%s: %s line %d exceeds size limit", __func__,
350 filename, lineno);
351 /* discard remainder of line */
352 while(fgetc(f) != '\n' && !feof(f))
353 ; /* nothing */
354 }
355 }
356 return -1;
357}