Package: e2fsprogs
Version: 1.44.0~rc1-1
Severity: important
Tags: patch

A code change introduced in version 1.44.0~rc1-1 according to the
autobuild logs causes the program to fail to build from source on hurd.

This is the build error:

> ../../../misc/mke2fs.c:2874:34: error: 'PATH_MAX' undeclared (first
> use in this function); did you mean 'INT8_MAX'?

As far as I can tell from the source, the PATH_MAX variable is used to
avoid having to count the number of characters in the device_name
string.  It seem like a better idea to use strlen() to avoid hardcoding
an upper limit to the length of a device path.  The following patch
fixes the build problem on Hurd.

I did not check if the device_name is a valid string (ie not NULL), as
the rest of the code assume it is valid (snprintf being the first call
that would fail if it is bogus).

--- e2fsprogs-1.44.0.orig/misc/mke2fs.c
+++ e2fsprogs-1.44.0/misc/mke2fs.c
@@ -16,8 +16,6 @@
  * enforced (but it's not much fun on a character device :-).
  */
 
-#define _XOPEN_SOURCE 600 /* for inclusion of PATH_MAX */
-
 #include "config.h"
 #include <stdio.h>
 #include <string.h>
@@ -2871,13 +2869,14 @@ int main (int argc, char *argv[])
        if (!quiet)
                flags |= EXT2_FLAG_PRINT_PROGRESS;
        if (android_sparse_file) {
-               android_sparse_params = malloc(PATH_MAX + 32);
+               int plen = strlen(device_name) + 32;
+               android_sparse_params = malloc(plen);
                if (!android_sparse_params) {
                        com_err(program_name, ENOMEM, "%s",
                                _("in malloc for android_sparse_params"));
                        exit(1);
                }
-               snprintf(android_sparse_params, PATH_MAX + 32, "(%s):%u:%u",
+               snprintf(android_sparse_params, plen, "(%s):%u:%u",
                         device_name, fs_param.s_blocks_count,
                         1024 << fs_param.s_log_block_size);
                retval = ext2fs_initialize(android_sparse_params, flags,
-- 
Happy hacking
Petter Reinholdtsen

Reply via email to