xdebug: FTBFS on hurd-i386 (for review)
Source: xdebug
Version: 2.2.4-1
Severity: important
Tags: patch
User: debian-hurd@lists.debian.org
Usertags: hurd
Hi,
Currently xdebug fails to build from source due to PATH_MAX being
used, and that constant is not defined on GNU/Hurd. The attached patch
avoid using PATH_MAX by allocating strings with malloc and free them
when not needed any longer. (is this patch totally wrong??)
Thanks!
--- a/xdebug-2.2.4/usefulstuff.c
+++ b/xdebug-2.2.4/usefulstuff.c
@@ -284,25 +284,27 @@ char *xdebug_raw_url_encode(char const *
char *xdebug_path_from_url(const char *fileurl TSRMLS_DC)
{
/* deal with file: url's */
- char dfp[PATH_MAX * 2];
- const char *fp = dfp, *efp = fileurl;
+ const char *dfp = NULL, *efp = fileurl;
#ifdef PHP_WIN32
int l = 0;
int i;
#endif
char *tmp = NULL, *ret = NULL;;
+ size_t len;
- memset(dfp, 0, sizeof(dfp));
- strncpy(dfp, efp, sizeof(dfp) - 1);
- xdebug_raw_url_decode(dfp, strlen(dfp));
- tmp = strstr(fp, "file://");
+ len = strlen(efp) + 1;
+ dfp = malloc(len);
+ memset(dfp, 0, len);
+ strncpy(dfp, efp, len);
+ xdebug_raw_url_decode(dfp, len - 1);
+ tmp = strstr(dfp, "file://");
if (tmp) {
- fp = tmp + 7;
- if (fp[0] == '/' && fp[2] == ':') {
- fp++;
+ dfp = tmp + 7;
+ if (dfp[0] == '/' && dfp[2] == ':') {
+ dfp++;
}
- ret = xdstrdup(fp);
+ ret = xdstrdup(dfp);
#ifdef PHP_WIN32
l = strlen(ret);
/* convert '/' to '\' */
@@ -316,6 +318,7 @@ char *xdebug_path_from_url(const char *f
ret = xdstrdup(fileurl);
}
+ free(dfp);
return ret;
}
Reply to: