Improve error checking
authorJohn Carr <jfc@mit.edu>
Sun, 23 Feb 1992 12:04:11 +0000 (12:04 +0000)
committerJohn Carr <jfc@mit.edu>
Sun, 23 Feb 1992 12:04:11 +0000 (12:04 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2209 dc483132-0cff-0310-8789-dd5450dbe970

src/admin/edit/dump.c

index 25b001cd096c805e48033476da9f2029b648f960..0727d27c4191029a73d99cd73f928235357fbd80 100644 (file)
@@ -244,10 +244,18 @@ void load_db(argc, argv)
                goto error_out;
        }
        for (;;) {
+               int nitems;
+
                lineno++;
                memset((char *)&entry, 0, sizeof(entry));
-               if (fscanf(f,"%d\t%d\t", &name_len, &mod_name_len) == EOF)
+               nitems = fscanf(f,"%d\t%d\t", &name_len, &mod_name_len);
+               if (nitems == EOF)
                        break;
+               if (nitems != 2) {
+                       fprintf(stderr, "Couldn't parse line #%d\n", lineno);
+                       load_error++;
+                       break;
+               }
                if (!(name = malloc(name_len+1))) {
                        com_err(argv[0], errno,
                                "While allocating space for name");