undo - stat(2) may not populate struct stat upon failure.
authorYONETANI Tomokazu <y0netan1@dragonflybsd.org>
Fri, 15 Oct 2010 01:20:48 +0000 (10:20 +0900)
committerYONETANI Tomokazu <y0netan1@dragonflybsd.org>
Fri, 15 Oct 2010 01:23:30 +0000 (10:23 +0900)
usr.bin/undo/undo.c

index cf78daa..5a58adc 100644 (file)
@@ -265,8 +265,7 @@ doiterate(const char *filename, const char *outFileName,
        collect_dir_history(filename, &error, &dir_tree);
        RB_FOREACH(tse1, undo_hist_entry_rb_tree, &dir_tree) {
                asprintf(&path, "%s@@0x%016jx", filename, (uintmax_t)tse1->tse.tid);
        collect_dir_history(filename, &error, &dir_tree);
        RB_FOREACH(tse1, undo_hist_entry_rb_tree, &dir_tree) {
                asprintf(&path, "%s@@0x%016jx", filename, (uintmax_t)tse1->tse.tid);
-               stat(path, &sb);
-               if (sb.st_mode & S_IFIFO) {
+               if (stat(path, &sb) == 0 && sb.st_mode & S_IFIFO) {
                        fprintf(stderr, "Warning: fake transaction id 0x%016jx\n", (uintmax_t)tse1->tse.tid);
                        continue;
                }
                        fprintf(stderr, "Warning: fake transaction id 0x%016jx\n", (uintmax_t)tse1->tse.tid);
                        continue;
                }