From: John Carr Date: Fri, 21 Aug 1992 02:39:58 +0000 (+0000) Subject: Read data into temporary variables to avoid dependencies on size of X-Git-Tag: krb5-1.0-beta2~126 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=debb7eb36558fd89bf53447b2af7cdc9e2faae92;p=krb5.git Read data into temporary variables to avoid dependencies on size of key version number data type. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2336 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/admin/edit/dump.c b/src/admin/edit/dump.c index 0727d27c4..a09225283 100644 --- a/src/admin/edit/dump.c +++ b/src/admin/edit/dump.c @@ -245,6 +245,7 @@ void load_db(argc, argv) } for (;;) { int nitems; + unsigned int tmp1, tmp2; lineno++; memset((char *)&entry, 0, sizeof(entry)); @@ -269,12 +270,17 @@ void load_db(argc, argv) load_error++; break; } - if (fscanf(f, "%s\t%d\t%d\t", name, &entry.key.keytype, + if (fscanf(f, "%s\t%d\t%d\t", name, &tmp1, &entry.key.length) != 3) { fprintf(stderr, "Couldn't parse line #%d\n", lineno); load_error++; break; } + /* keytype is probably a short, but might not be. + To avoid problems with scanf, read into a variable of + known type then copy the value. */ + entry.key.keytype = tmp1; + if (!(entry.key.contents = (krb5_octet *) malloc(entry.key.length+1))) { free(name); free(mod_name); @@ -293,8 +299,8 @@ void load_db(argc, argv) entry.key.contents[i] = align; } if (fscanf(f, "\t%u\t%u\t%u\t%u\t%u\t%s\t%u\t%u\t%u\t%u\t", - &entry.kvno, &entry.max_life, - &entry.max_renewable_life, &entry.mkvno, + &tmp1, &entry.max_life, + &entry.max_renewable_life, &tmp2, &entry.expiration, mod_name, &entry.mod_date, &entry.attributes, &stype, &slength) != 10) { @@ -303,6 +309,8 @@ void load_db(argc, argv) load_error++; break; } + entry.kvno = tmp1; + entry.mkvno = tmp2; entry.salt_type = stype; entry.salt_length = slength; if (slength) {