[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

rserve: FTBFS on hurd-i386 (for review)



(Sent to debian-hurd for review)

Source: rserve
Version: 1.7-3-1
Severity: important
Tags: patch
User: debian-hurd@lists.debian.org
Usertags: hurd

Hi,

rserve fails to build from source on GNU/Hurd since PATH_MAX is not
defined.

1) src/Rserv.c: Since PATH_MAX is not defined use the st_size parameter
of a previously made lstat() call:
static void rm_rf(const char *what) {
  struct stat st;
  if (!lstat(what, &st)) { (...see patch)
together with strlen() (and allocating space for / and the
string terminating \0).

(Problems can arise since rm_rf() is recursive?? Help needed here!)

The attached patch fixes these problems.

Thanks!


--- a/src/Rserv.c	2013-08-21 23:09:33.000000000 +0200
+++ b/src/Rserv.c	2014-01-28 14:07:37.000000000 +0100
@@ -2206,14 +2206,17 @@
 		chmod(what, st.st_mode | ((st.st_mode & S_IFDIR) ? S_IRWXU : S_IWUSR));
 		if (st.st_mode & S_IFDIR) { /* dirs need to be deleted recursively */
 			DIR *dir = opendir(what);
-			char path[PATH_MAX];
+			char *path = NULL;
 			if (dir) {
 				struct dirent *d;
 				while ((d = readdir(dir))) {
 					if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
 						continue;
-					snprintf(path, sizeof(path), "%s/%s", what, d->d_name);
-					rm_rf(path);
+					int len = st.st_size + strlen(d->d_name) + 1;
+					path = (char*)malloc(len);
+					snprintf(path, len, "%s/%s", what, d->d_name);
+					// ?? rm_rf(path);
+					free(path);
 				}
 				closedir(dir);
 			}

Reply to: