From 941ffd2aed35c05346c1c77ab3cbfcc75b8e494a Mon Sep 17 00:00:00 2001 From: sin Date: Fri, 27 Jun 2014 11:47:03 +0100 Subject: [PATCH] Bail out on path truncation --- switch_root.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/switch_root.c b/switch_root.c index 49a49e7..7500f8f 100644 --- a/switch_root.c +++ b/switch_root.c @@ -36,8 +36,10 @@ delete_content(const char *dir, dev_t curdevice) continue; /* build path and dive deeper */ - strlcat(path, dir, sizeof(path)); - strlcat(path, dent->d_name, sizeof(path)); + if (strlcat(path, dir, sizeof(path)) >= sizeof(path)) + eprintf("path too long\n"); + if (strlcat(path, dent->d_name, sizeof(path)) >= sizeof(path)) + eprintf("path too long\n"); delete_content(path, curdevice); path[0] = 0;