aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2011-11-10 17:26:32 +0000
committerRob Austein <sra@hactrn.net>2011-11-10 17:26:32 +0000
commitacf83a1b20cc2802dad24aa2422c0bd54951c8e7 (patch)
treed1fdb65a6720cf43c39afe355813ce452217f4c5
parent5c9c1fa8ad4b229d73551804c35906186f5fa2e9 (diff)
Handle traversal of empty backup directory with no manifest correctly,
now that this bug isn't masked by the one I fixed earlier today. svn path=/trunk/; revision=4081
-rw-r--r--rcynic/rcynic.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/rcynic/rcynic.c b/rcynic/rcynic.c
index 5b780f47..64f44096 100644
--- a/rcynic/rcynic.c
+++ b/rcynic/rcynic.c
@@ -1554,6 +1554,17 @@ static walk_ctx_t *walk_ctx_stack_head(STACK_OF(walk_ctx_t) *wsk)
}
/**
+ * Whether we're done iterating over a walk context. Think of this as
+ * the thing you call (negated) in the second clause of a conceptual
+ * "for" loop.
+ */
+static int walk_ctx_loop_done(STACK_OF(walk_ctx_t) *wsk)
+{
+ walk_ctx_t *w = walk_ctx_stack_head(wsk);
+ return wsk == NULL || w == NULL || w->state >= walk_state_done;
+}
+
+/**
* Walk context iterator. Think of this as the thing you call in the
* third clause of a conceptual "for" loop: this reinitializes as
* necessary for the next pass through the loop.
@@ -1579,26 +1590,17 @@ static void walk_ctx_loop_next(const rcynic_ctx_t *rc, STACK_OF(walk_ctx_t) *wsk
return;
}
- if (w->state < walk_state_done) {
+ while (!walk_ctx_loop_done(wsk)) {
w->state++;
w->manifest_iteration = 0;
w->filename_iteration = 0;
sk_OPENSSL_STRING_pop_free(w->filenames, OPENSSL_STRING_free);
w->filenames = directory_filenames(rc, w->state, &w->certinfo.sia);
+ if (w->manifest != NULL || w->filenames != NULL)
+ return;
}
}
-/**
- * Whether we're done iterating over a walk context. Think of this as
- * the thing you call (negated) in the second clause of a conceptual
- * "for" loop.
- */
-static int walk_ctx_loop_done(STACK_OF(walk_ctx_t) *wsk)
-{
- walk_ctx_t *w = walk_ctx_stack_head(wsk);
- return wsk == NULL || w == NULL || w->state >= walk_state_done;
-}
-
static int check_manifest(rcynic_ctx_t *rc, STACK_OF(walk_ctx_t) *wsk);
/**