diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 1998-05-15 00:58:55 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 1998-05-15 00:58:55 +0000 |
commit | f670f62ca6037f20bbfe4f643aa3d60744a36962 (patch) | |
tree | 20b275fda5d8e981014b346f83289f8c6f83c015 /kerberosIV | |
parent | 403e9381deb2c88b9d0161c34e0f19ded905412a (diff) |
don't overflow buffers.
Diffstat (limited to 'kerberosIV')
-rw-r--r-- | kerberosIV/krb/get_host.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/kerberosIV/krb/get_host.c b/kerberosIV/krb/get_host.c index aff806a8d02..57a2123a1b9 100644 --- a/kerberosIV/krb/get_host.c +++ b/kerberosIV/krb/get_host.c @@ -1,4 +1,4 @@ -/* $OpenBSD: get_host.c,v 1.6 1998/03/25 21:50:11 art Exp $ */ +/* $OpenBSD: get_host.c,v 1.7 1998/05/15 00:58:54 art Exp $ */ /* $KTH: get_host.c,v 1.31 1997/09/26 17:42:37 joda Exp $ */ /* @@ -214,7 +214,17 @@ read_file(const char *filename, const char *r) if(f == NULL) return -1; while(fgets(line, sizeof(line), f) != NULL) { - n = sscanf(line, "%s %s admin %s", realm, address, scratch); + char *format = NULL; + + asprintf(&format, "%%%ds %%%ds admin %%%ds", sizeof(realm) - 1, + sizeof(address) - 1, sizeof(scratch) - 1); + if (format == NULL) { + fclose(f); + return -1; + } + n = sscanf(line, format, realm, address, scratch); + free(format); + format = NULL; if(n == 2 || n == 3){ if(strcmp(realm, r)) continue; |