]> git.webhop.me Git - bs-cst-neutrino-hd.git/commitdiff
fix build of util-linux with uclibc-ng
authorMarkham <markham001@gmx.de>
Sun, 20 May 2018 12:17:09 +0000 (14:17 +0200)
committerMarkham <markham001@gmx.de>
Sun, 20 May 2018 12:17:09 +0000 (14:17 +0200)
archive-patches/util-linux-2.25.2-lib-colors-use-static-buffers-when-parse-scheme.patch [new file with mode: 0644]
archive-patches/util-linux-2.25.2-no-printf-alloc.patch [new file with mode: 0644]
make/libraries.mk

diff --git a/archive-patches/util-linux-2.25.2-lib-colors-use-static-buffers-when-parse-scheme.patch b/archive-patches/util-linux-2.25.2-lib-colors-use-static-buffers-when-parse-scheme.patch
new file mode 100644 (file)
index 0000000..a837eaa
--- /dev/null
@@ -0,0 +1,128 @@
+From 6508db29ded734ac4ff5e5e19486c143c9eb3d89 Mon Sep 17 00:00:00 2001
+From: Karel Zak <kzak@redhat.com>
+Date: Fri, 21 Nov 2014 12:23:47 +0100
+Subject: [PATCH] lib/colors: use static buffers when parse scheme
+
+* use static buffers when parse scheme colors
+* cleanup deallocation on error in sequence parser
+
+Signed-off-by: Karel Zak <kzak@redhat.com>
+---
+
+This is modified upstream patch.
+
+--- a/lib/colors.c
++++ b/lib/colors.c
+@@ -416,28 +416,31 @@ static int colors_add_scheme(struct ul_c
+                            char *name,
+                            char *seq0)
+ {
+-      struct ul_color_scheme *cs;
+-      char *seq;
++      struct ul_color_scheme *cs = NULL;
++      char *seq = NULL;
+       int rc;
+       if (!cc || !name || !*name || !seq0 || !*seq0)
+               return -EINVAL;
+       rc = cn_sequence(seq0, &seq);
+-      free(seq0);
+       if (rc)
+               return rc;
++      rc = -ENOMEM;
++
+       /* convert logical name (e.g. "red") to real ESC code */
+       if (isalpha(*seq)) {
+               const char *s = color_sequence_from_colorname(seq);
+               char *p;
+-              if (!s)
+-                      return -EINVAL;
++              if (!s) {
++                      rc = -EINVAL;
++                      goto err;
++              }
+               p = strdup(s);
+               if (!p)
+-                      return -ENOMEM;
++                      goto err;
+               free(seq);
+               seq = p;
+       }
+@@ -447,17 +450,28 @@ static int colors_add_scheme(struct ul_c
+               void *tmp = realloc(cc->schemes, (cc->nschemes + 10)
+                                       * sizeof(struct ul_color_scheme));
+               if (!tmp)
+-                      return -ENOMEM;
++                      goto err;
+               cc->schemes = tmp;
+               cc->schemes_sz = cc->nschemes + 10;
+       }
+       /* add a new item */
+-      cs = &cc->schemes[cc->nschemes++];
+-      cs->name = name;
++      cs = &cc->schemes[cc->nschemes];
+       cs->seq = seq;
++      cs->name = strdup(name);
++      if (!cs->name)
++              goto err;
++      cc->nschemes++;
+       return 0;
++err:
++      if (cs) {
++              free(cs->seq);
++              free(cs->name);
++              cs->seq = cs->name = NULL;
++      } else
++              free(seq);
++      return rc;
+ }
+ /*
+@@ -543,7 +557,8 @@ static int colors_read_schemes(struct ul
+ {
+       int rc = 0;
+       FILE *f = NULL;
+-      char buf[BUFSIZ];
++      char buf[BUFSIZ],
++           cn[129], seq[129];
+       if (!cc->configured)
+               rc = colors_read_configuration(cc);
+@@ -560,7 +575,6 @@ static int colors_read_schemes(struct ul
+       }
+       while (fgets(buf, sizeof(buf), f)) {
+-              char *cn = NULL, *seq = NULL;
+               char *p = strchr(buf, '\n');
+               if (!p) {
+@@ -576,17 +590,14 @@ static int colors_read_schemes(struct ul
+               if (*p == '\0' || *p == '#')
+                       continue;
+-              rc = sscanf(p,  UL_SCNsA" "     /* name */
+-                              UL_SCNsA,       /* color */
+-                              &cn, &seq);
+-              if (rc == 2 && cn && seq)
++              rc = sscanf(p, "%128[^ ] %128[^\n ]", cn, seq);
++              if (rc == 2 && *cn && *seq) {
+                       rc = colors_add_scheme(cc, cn, seq);    /* set rc=0 on success */
+-              if (rc) {
+-                      free(cn);
+-                      free(seq);
++                      if (rc)
++                              goto done;
+               }
+-              rc = 0;
+       }
++      rc = 0;
+ done:
+       if (f)
+
+
diff --git a/archive-patches/util-linux-2.25.2-no-printf-alloc.patch b/archive-patches/util-linux-2.25.2-no-printf-alloc.patch
new file mode 100644 (file)
index 0000000..1c31ab7
--- /dev/null
@@ -0,0 +1,106 @@
+--- a/configure.ac
++++ b/configure.ac
+@@ -798,7 +798,6 @@ AC_ARG_ENABLE([libmount],
+ )
+ UL_BUILD_INIT([libmount])
+ UL_REQUIRES_BUILD([libmount], [libblkid])
+-UL_REQUIRES_HAVE([libmount], [scanf_alloc_modifier], [scanf string alloc modifier])
+ AM_CONDITIONAL([BUILD_LIBMOUNT], [test "x$build_libmount" = xyes])
+ AM_CONDITIONAL([BUILD_LIBMOUNT_TESTS], [test "x$build_libmount" = xyes -a "x$enable_static" = xyes])
+--- a/libmount/src/tab_parse.c
++++ b/libmount/src/tab_parse.c
+@@ -22,6 +22,10 @@
+ #include "pathnames.h"
+ #include "strutils.h"
++#ifndef HAVE_SCANF_MS_MODIFIER
++# define UL_SCNsA "%s"
++#endif
++
+ static int next_number(char **s, int *num)
+ {
+       char *end = NULL;
+@@ -52,16 +56,31 @@ static int mnt_parse_table_line(struct l
+       int rc, n = 0, xrc;
+       char *src = NULL, *fstype = NULL, *optstr = NULL;
++#ifndef HAVE_SCANF_MS_MODIFIER
++      size_t len = strlen(s) + 1;
++      src = malloc(len);
++      fstype = malloc(len);
++      fs->target = malloc(len);
++      optstr = malloc(len);
++#endif
++
+       rc = sscanf(s,  UL_SCNsA" "     /* (1) source */
+                       UL_SCNsA" "     /* (2) target */
+                       UL_SCNsA" "     /* (3) FS type */
+                       UL_SCNsA" "     /* (4) options */
+                       "%n",           /* byte count */
++#ifdef HAVE_SCANF_MS_MODIFIER
+                       &src,
+                       &fs->target,
+                       &fstype,
+                       &optstr,
++#else
++                      src,
++                      fs->target,
++                      fstype,
++                      optstr,
++#endif
+                       &n);
+       xrc = rc;
+@@ -127,6 +146,16 @@ static int mnt_parse_mountinfo_line(stru
+       unsigned int maj, min;
+       char *fstype = NULL, *src = NULL, *p;
++#ifndef HAVE_SCANF_MS_MODIFIER
++      size_t len = strlen(s) + 1;
++      fs->root = malloc(len);
++      fs->target = malloc(len);
++      fs->vfs_optstr = malloc(len);
++      fs->fs_optstr = malloc(len);
++      fstype = malloc(len);
++      src = malloc(len);
++#endif
++
+       rc = sscanf(s,  "%d "           /* (1) id */
+                       "%d "           /* (2) parent */
+                       "%u:%u "        /* (3) maj:min */
+@@ -138,9 +167,15 @@ static int mnt_parse_mountinfo_line(stru
+                       &fs->id,
+                       &fs->parent,
+                       &maj, &min,
++#ifdef HAVE_SCANF_MS_MODIFIER
+                       &fs->root,
+                       &fs->target,
+                       &fs->vfs_optstr,
++#else
++                      fs->root,
++                      fs->target,
++                      fs->vfs_optstr,
++#endif
+                       &end);
+       if (rc >= 7 && end > 0)
+@@ -160,9 +195,15 @@ static int mnt_parse_mountinfo_line(stru
+                       UL_SCNsA" "     /* (9) source */
+                       UL_SCNsA,       /* (10) fs options (fs specific) */
++#ifdef HAVE_SCANF_MS_MODIFIER
+                       &fstype,
+                       &src,
+                       &fs->fs_optstr);
++#else
++                      fstype,
++                      src,
++                      fs->fs_optstr);
++#endif
+       if (rc >= 10) {
+               size_t sz;
+
+
index 319a2f85a02765830ecee827ea6230b31425f0fd..4a321c5ede324a006c908b9597b1a8bc4dd06276 100755 (executable)
@@ -75,6 +75,8 @@ $(D)/util-linux: $(D)/libncurses $(ARCHIVE)/util-linux-$(UTIL_LINUX_VER).tar.xz
        $(START_BUILD)
        $(UNTAR)/util-linux-$(UTIL_LINUX_VER).tar.xz
        cd $(BUILD_TMP)/util-linux-$(UTIL_LINUX_VER) && \
+               $(PATCH)/util-linux-2.25.2-no-printf-alloc.patch && \
+               $(PATCH)/util-linux-2.25.2-lib-colors-use-static-buffers-when-parse-scheme.patch && \
                autoreconf -fi && \
                $(CONFIGURE) \
                        --prefix= \