From 1703c6841b397d92c278fcb5bac749b0ab35e33a Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 11 Feb 2013 08:43:01 +0000 Subject: [PATCH] daemon: find0: Remove use of PATH_MAX. --- daemon/find.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/daemon/find.c b/daemon/find.c index 7749e4df4..42cbd2e73 100644 --- a/daemon/find.c +++ b/daemon/find.c @@ -51,14 +51,6 @@ input_to_nul (FILE *fp, char *buf, size_t maxlen) return -1; } -/* The code below assumes each path returned can fit into a protocol - * chunk. If this turns out not to be true at some point in the - * future then we'll need to modify the code a bit to handle it. - */ -#if PATH_MAX > GUESTFS_MAX_CHUNK_SIZE -#error "PATH_MAX > GUESTFS_MAX_CHUNK_SIZE" -#endif - /* Has one FileOut parameter. */ int do_find0 (const char *dir) @@ -68,7 +60,7 @@ do_find0 (const char *dir) FILE *fp; CLEANUP_FREE char *cmd = NULL; CLEANUP_FREE char *sysrootdir = NULL; - size_t sysrootdirlen, len; + size_t sysrootdirlen; char str[GUESTFS_MAX_CHUNK_SIZE]; sysrootdir = sysroot_path (dir); @@ -109,8 +101,13 @@ do_find0 (const char *dir) */ reply (NULL, NULL); + /* The code below assumes each path returned can fit into a protocol + * chunk (if not you'll get a runtime protocol error). If this + * turns out not to be a problem at some point in the future then + * we'll need to modify the code to handle it. XXX + */ while ((r = input_to_nul (fp, str, GUESTFS_MAX_CHUNK_SIZE)) > 0) { - len = strlen (str); + size_t len = strlen (str); if (len <= sysrootdirlen) continue;