From 8a0bcd56eeb5773d4001ea9c0fd9c299542507d0 Mon Sep 17 00:00:00 2001 From: YONETANI Tomokazu Date: Fri, 15 Oct 2010 10:20:48 +0900 Subject: [PATCH] undo - stat(2) may not populate struct stat upon failure. --- usr.bin/undo/undo.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/usr.bin/undo/undo.c b/usr.bin/undo/undo.c index cf78daa2d3..5a58adc636 100644 --- a/usr.bin/undo/undo.c +++ b/usr.bin/undo/undo.c @@ -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); - 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; } -- 2.41.0