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

Bug#717723: marked as done (libxkbcommon: FTBFS on hurd-i386: unconditional usage of PATH_MAX)



Your message dated Tue, 10 Sep 2013 00:03:37 +0000
with message-id <E1VJBQf-0004vr-Si@franck.debian.org>
and subject line Bug#717723: fixed in libxkbcommon 0.3.1-2
has caused the Debian Bug report #717723,
regarding libxkbcommon: FTBFS on hurd-i386: unconditional usage of PATH_MAX
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
717723: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=717723
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Source: libxkbcommon
Version: 0.3.1-1
Severity: important
Tags: patch fixed-upstream
User: debian-hurd@lists.debian.org
Usertags: hurd
Control: forwarded -1 https://bugs.freedesktop.org/show_bug.cgi?id=67229

Hi,

libxkbcommon 0.3.1 does not compile on GNU/Hurd [1].

The problem is the unconditional usage of PATH_MAX, optional in POSIX
and not provided on the Hurd.

I reported the problem upstream [2] with a patch, which got accepted.
Could you please backport it? It applies fine to the released 0.3.1.

[1] https://buildd.debian.org/status/fetch.php?pkg=libxkbcommon&arch=hurd-i386&ver=0.3.1-1&stamp=1370737530
[2] https://bugs.freedesktop.org/show_bug.cgi?id=67229

Thanks,
-- 
Pino
>From b0ad0cbf99c835ff346f0cd0f3aa0d2e45686923 Mon Sep 17 00:00:00 2001
From: Pino Toscano <toscano.pino@tiscali.it>
Date: Wed, 24 Jul 2013 10:05:02 +0200
Subject: [PATCH] Get rid of the usage of PATH_MAX

PATH_MAX is optional in POSIX, so avoid its unconditional usage
allocating and freeing buffers as needed.
To avoid too many malloc/free in the for loop in FindFileInXkbPath,
a buffer is grown according to the size needed at each iteration.
---
 src/xkbcomp/include.c | 34 +++++++++++++++++++++++++++-------
 test/common.c         | 41 ++++++++++++++++++++++++++++++++++-------
 test/test.h           |  2 +-
 3 files changed, 62 insertions(+), 15 deletions(-)

diff --git a/src/xkbcomp/include.c b/src/xkbcomp/include.c
index b4a4014..280bbbd 100644
--- a/src/xkbcomp/include.c
+++ b/src/xkbcomp/include.c
@@ -199,17 +199,34 @@ FindFileInXkbPath(struct xkb_context *ctx, const char *name,
 {
     unsigned int i;
     FILE *file = NULL;
-    char buf[PATH_MAX];
+    char *buf = NULL;
     const char *typeDir;
+    size_t buf_size = 0, typeDirLen, name_len;
 
     typeDir = DirectoryForInclude(type);
+    typeDirLen = strlen(typeDir);
+    name_len = strlen(name);
 
     for (i = 0; i < xkb_context_num_include_paths(ctx); i++) {
-        int ret = snprintf(buf, sizeof(buf), "%s/%s/%s",
-                           xkb_context_include_path_get(ctx, i),
-                           typeDir, name);
-        if (ret >= (ssize_t) sizeof(buf)) {
-            log_err(ctx, "File name (%s/%s/%s) too long\n",
+        size_t new_buf_size = strlen(xkb_context_include_path_get(ctx, i)) +
+                              typeDirLen + name_len + 3;
+        int ret;
+        if (new_buf_size > buf_size) {
+            void *buf_new = realloc(buf, new_buf_size);
+            if (buf_new) {
+                buf_size = new_buf_size;
+                buf = buf_new;
+            } else {
+                log_err(ctx, "Cannot realloc for name (%s/%s/%s)\n",
+                        xkb_context_include_path_get(ctx, i), typeDir, name);
+                continue;
+            }
+        }
+        ret = snprintf(buf, buf_size, "%s/%s/%s",
+                       xkb_context_include_path_get(ctx, i),
+                       typeDir, name);
+        if (ret < 0) {
+            log_err(ctx, "snprintf error (%s/%s/%s)\n",
                     xkb_context_include_path_get(ctx, i), typeDir, name);
             continue;
         }
@@ -242,11 +259,14 @@ FindFileInXkbPath(struct xkb_context *ctx, const char *name,
                         xkb_context_failed_include_path_get(ctx, i));
         }
 
+        free(buf);
         return NULL;
     }
 
     if (pathRtrn)
-        *pathRtrn = strdup(buf);
+        *pathRtrn = buf;
+    else
+        free(buf);
     return file;
 }
 
diff --git a/test/common.c b/test/common.c
index 7b4ee00..796904e 100644
--- a/test/common.c
+++ b/test/common.c
@@ -138,13 +138,22 @@ test_key_seq(struct xkb_keymap *keymap, ...)
     return ret;
 }
 
-const char *
+char *
 test_get_path(const char *path_rel)
 {
-    static char path[PATH_MAX];
+    char *path;
+    size_t path_len;
     const char *srcdir = getenv("srcdir");
 
-    snprintf(path, PATH_MAX - 1,
+    path_len = strlen(srcdir ? srcdir : ".") +
+               strlen(path_rel ? path_rel : "") + 12;
+    path = malloc(path_len);
+    if (!path) {
+        fprintf(stderr, "Failed to allocate path (%d chars) for %s\n",
+                (int) path_len, path);
+        return NULL;
+    }
+    snprintf(path, path_len,
              "%s/test/data/%s", srcdir ? srcdir : ".",
              path_rel ? path_rel : "");
 
@@ -155,10 +164,15 @@ char *
 test_read_file(const char *path_rel)
 {
     struct stat info;
-    char *ret, *tmp;
+    char *ret, *tmp, *path;
     int fd, count, remaining;
 
-    fd = open(test_get_path(path_rel), O_RDONLY);
+    path = test_get_path(path_rel);
+    if (!path)
+        return NULL;
+
+    fd = open(path, O_RDONLY);
+    free(path);
     if (fd < 0)
         return NULL;
 
@@ -195,6 +209,7 @@ test_get_context(enum test_context_flags test_flags)
 {
     enum xkb_context_flags ctx_flags;
     struct xkb_context *ctx;
+    char *path;
 
     ctx_flags = XKB_CONTEXT_NO_DEFAULT_INCLUDES;
     if (test_flags & CONTEXT_ALLOW_ENVIRONMENT_NAMES) {
@@ -212,7 +227,12 @@ test_get_context(enum test_context_flags test_flags)
     if (!ctx)
         return NULL;
 
-    xkb_context_include_path_append(ctx, test_get_path(""));
+    path = test_get_path("");
+    if (!path)
+        return NULL;
+
+    xkb_context_include_path_append(ctx, path);
+    free(path);
 
     return ctx;
 }
@@ -222,11 +242,16 @@ test_compile_file(struct xkb_context *context, const char *path_rel)
 {
     struct xkb_keymap *keymap;
     FILE *file;
-    const char *path = test_get_path(path_rel);
+    char *path;
+
+    path = test_get_path(path_rel);
+    if (!path)
+        return NULL;
 
     file = fopen(path, "r");
     if (!file) {
         fprintf(stderr, "Failed to open path: %s\n", path);
+        free(path);
         return NULL;
     }
     assert(file != NULL);
@@ -237,10 +262,12 @@ test_compile_file(struct xkb_context *context, const char *path_rel)
 
     if (!keymap) {
         fprintf(stderr, "Failed to compile path: %s\n", path);
+        free(path);
         return NULL;
     }
 
     fprintf(stderr, "Successfully compiled path: %s\n", path);
+    free(path);
 
     return keymap;
 }
diff --git a/test/test.h b/test/test.h
index 804606e..95afbea 100644
--- a/test/test.h
+++ b/test/test.h
@@ -49,7 +49,7 @@ test_key_seq(struct xkb_keymap *keymap, ...);
 int
 test_key_seq_va(struct xkb_keymap *keymap, va_list args);
 
-const char *
+char *
 test_get_path(const char *path_rel);
 
 char *
-- 
1.8.3.2


--- End Message ---
--- Begin Message ---
Source: libxkbcommon
Source-Version: 0.3.1-2

We believe that the bug you reported is fixed in the latest version of
libxkbcommon, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 717723@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Emilio Pozuelo Monfort <pochu@debian.org> (supplier of updated libxkbcommon package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.8
Date: Tue, 10 Sep 2013 01:45:53 +0200
Source: libxkbcommon
Binary: libxkbcommon0 libxkbcommon-dev
Architecture: source amd64
Version: 0.3.1-2
Distribution: unstable
Urgency: low
Maintainer: Debian X Strike Force <debian-x@lists.debian.org>
Changed-By: Emilio Pozuelo Monfort <pochu@debian.org>
Description: 
 libxkbcommon-dev - library interface to the XKB compiler - development files
 libxkbcommon0 - library interface to the XKB compiler - shared library
Closes: 715560 717723
Changes: 
 libxkbcommon (0.3.1-2) unstable; urgency=low
 .
   * Cherry-pick ec9a02 from upstream, fixes FTBFS on hurd. Closes: #717723.
   * Re-enable the test suite on !linux. Thanks Pino Toscano. Closes: #715560.
Checksums-Sha1: 
 48516faafb6e6ebb991ed350ae4ef436a99f49ac 1449 libxkbcommon_0.3.1-2.dsc
 f58162763148cfe5a87cbb7035f3a80d59e949a2 109614 libxkbcommon_0.3.1-2.diff.gz
 9352135fc4083349e485ee360692e9994b7cb791 121112 libxkbcommon0_0.3.1-2_amd64.deb
 1c0a64f489fc4395db28208ca9588e77b47161b3 161130 libxkbcommon-dev_0.3.1-2_amd64.deb
Checksums-Sha256: 
 0d9b9ca3822d065e99709d7efcf1dbf2e0555be625fc8a4f59160fdef3067739 1449 libxkbcommon_0.3.1-2.dsc
 93d51a1b768006e6e55cab446f6b46fc6ee290d1e951599a7b95029c884bae9e 109614 libxkbcommon_0.3.1-2.diff.gz
 41c37edf586f6cf1c290151c78f5c7433c88fe011a3db5ecd0458d6cf9180702 121112 libxkbcommon0_0.3.1-2_amd64.deb
 3c96622139260cd3926dd07e48d87627d67aea65b3a2f86ace9baa7210e16a88 161130 libxkbcommon-dev_0.3.1-2_amd64.deb
Files: 
 891169f558a2952cdb1ed6eb57fe8f5c 1449 x11 optional libxkbcommon_0.3.1-2.dsc
 04a7608155890837ea264148b116eaf4 109614 x11 optional libxkbcommon_0.3.1-2.diff.gz
 8eeff5217a655d042e001a70e12dfee0 121112 libs optional libxkbcommon0_0.3.1-2_amd64.deb
 c6de9f553afa427c2663396b790d271a 161130 libdevel extra libxkbcommon-dev_0.3.1-2_amd64.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)

iEYEARECAAYFAlIuXr4ACgkQhTV17EoIsv4mggCgqqBaybKyMhb8PrRqOISJr9Vp
qpsAn07r4UhNWAf/iypU3Iu7HPrx0df4
=Gds4
-----END PGP SIGNATURE-----

--- End Message ---

Reply to: