Re: gputils: FTBFS on hurd-i386 (for review)
On Fri, Mar 31, 2017 at 03:13:03PM +0200, Svante Signell wrote:
> Source: gputils
> Version: 1.4.0-0.1
> Severity: important
> Tags: patch
> User: debian-hurd@lists.debian.org
> Usertags: hurd
>
> Hi,
>
> gputils currently FTBFS on GNU/Hurd due to PATH_MAX not being defined. The
> attached patch fixes this issue by allocating strings dynamically and remove
> them when not needed any more.
>
> Thanks!
> Index: gputils-1.4.0/gplink/gplink.c
> ===================================================================
> --- gputils-1.4.0.orig/gplink/gplink.c
> +++ gputils-1.4.0/gplink/gplink.c
> @@ -321,9 +321,11 @@ gplink_open_coff(const char *name)
> gp_object_type *object;
> gp_archive_type *archive;
> FILE *coff;
> - char file_name[PATH_MAX + 1];
> + char *file_name = NULL;
> + int len = strlen(name) + 1;
>
> - strncpy(file_name, name, sizeof(file_name));
> + file_name = malloc(len);
> + strncpy(file_name, name, len);
>
> coff = fopen(file_name, "rb");
> if ((coff == NULL) && (strchr(file_name, PATH_CHAR) == 0)) {
> @@ -331,7 +333,9 @@ gplink_open_coff(const char *name)
> int i;
>
> for (i = 0; i < state.numpaths; i++) {
> - snprintf(file_name, sizeof(file_name), "%s" COPY_CHAR "%s", state.paths[i], name);
> + len = snprintf(NULL, 0, "%s" COPY_CHAR "%s", state.paths[i], name);
This one seems to be missing a + 1.
Regards,
James
Reply to: