Re: pristine-tar: FTBFS on hurd-i386 (for review)
On Tue, 2014-02-11 at 18:26 +0100, Samuel Thibault wrote:
> Svante Signell, le Tue 11 Feb 2014 18:17:45 +0100, a écrit :
> > @@ -531,6 +533,7 @@
> > argv[i++] = level_buf;
> > argv[i++] = NULL;
> >
> > + /* FIXME: since exevp don't return exec_buf is defined static */
>
> There is no need to make it static: execvp does not return simply
> because it puts another program in the process. You thus don't even need
> to care where the data has been allocated: it'll be completely wiped
> once exec succeeds.
>
> Also, I guess you have not really understood what really get static:
>
> static char *foo;
>
> means that it's the foo pointer whose allocation is made static. Not the
> data pointed by foo...
Maybe I got it wrong then, perhaps const would be better. Anyway, in
this case it doesn't matter as you say.
> Apart from that, it seems fine.
New patch attached.
--- a/zgz/zgz.c 2013-09-04 04:15:45.000000000 +0200
+++ b/zgz/zgz.c 2014-02-11 18:49:04.000000000 +0100
@@ -518,12 +518,14 @@
static void
shamble(char *zombie, int level)
{
- char exec_buf[PATH_MAX];
+ char *exec_buf;
char level_buf[3];
char *argv[3];
- int i;
+ int i, len;
- snprintf(exec_buf, sizeof(exec_buf), "%s/%s", PKGLIBDIR, zombie);
+ len = strlen(PKGLIBDIR) + 1 + strlen(zombie) + 1;
+ exec_buf = malloc(len);
+ snprintf(exec_buf, len, "%s/%s", PKGLIBDIR, zombie);
snprintf(level_buf, sizeof(level_buf), "-%i", level);
i = 0;
@@ -540,10 +542,10 @@
static void
rebrain(char *zombie, char *program, int level)
{
- char path_buf[PATH_MAX];
+ char *path_buf = NULL;
char level_buf[3];
char *argv[3];
- int i;
+ int i, len;
#if defined(__APPLE__) && defined(__MACH__)
# define LD_PATH_VAR "DYLD_LIBRARY_PATH"
@@ -551,9 +553,11 @@
# define LD_PATH_VAR "LD_LIBRARY_PATH"
#endif
- snprintf(path_buf, sizeof(path_buf), "%s/%s", PKGLIBDIR, zombie);
+ len = strlen(PKGLIBDIR) + 1 + strlen(zombie) + 1;
+ snprintf(path_buf, len, "%s/%s", PKGLIBDIR, zombie);
/* FIXME - should append, not overwrite */
setenv(LD_PATH_VAR, path_buf, 1);
+ free(path_buf);
snprintf(level_buf, sizeof(level_buf), "-%i", level);
Reply to: