ad9eef0959bf0c8ce269e8039d4d05ef58e1d527
[openwrt/openwrt.git] / package / utils / util-linux / patches / 001-no-printf-alloc.patch
1 --- a/configure.ac
2 +++ b/configure.ac
3 @@ -798,7 +798,6 @@ AC_ARG_ENABLE([libmount],
4 )
5 UL_BUILD_INIT([libmount])
6 UL_REQUIRES_BUILD([libmount], [libblkid])
7 -UL_REQUIRES_HAVE([libmount], [scanf_alloc_modifier], [scanf string alloc modifier])
8 AM_CONDITIONAL([BUILD_LIBMOUNT], [test "x$build_libmount" = xyes])
9 AM_CONDITIONAL([BUILD_LIBMOUNT_TESTS], [test "x$build_libmount" = xyes -a "x$enable_static" = xyes])
10
11 --- a/libmount/src/tab_parse.c
12 +++ b/libmount/src/tab_parse.c
13 @@ -22,6 +22,10 @@
14 #include "pathnames.h"
15 #include "strutils.h"
16
17 +#ifndef HAVE_SCANF_MS_MODIFIER
18 +# define UL_SCNsA "%s"
19 +#endif
20 +
21 static int next_number(char **s, int *num)
22 {
23 char *end = NULL;
24 @@ -52,16 +56,31 @@ static int mnt_parse_table_line(struct l
25 int rc, n = 0, xrc;
26 char *src = NULL, *fstype = NULL, *optstr = NULL;
27
28 +#ifndef HAVE_SCANF_MS_MODIFIER
29 + size_t len = strlen(s) + 1;
30 + src = malloc(len);
31 + fstype = malloc(len);
32 + fs->target = malloc(len);
33 + optstr = malloc(len);
34 +#endif
35 +
36 rc = sscanf(s, UL_SCNsA" " /* (1) source */
37 UL_SCNsA" " /* (2) target */
38 UL_SCNsA" " /* (3) FS type */
39 UL_SCNsA" " /* (4) options */
40 "%n", /* byte count */
41
42 +#ifdef HAVE_SCANF_MS_MODIFIER
43 &src,
44 &fs->target,
45 &fstype,
46 &optstr,
47 +#else
48 + src,
49 + fs->target,
50 + fstype,
51 + optstr,
52 +#endif
53 &n);
54 xrc = rc;
55
56 @@ -127,6 +146,16 @@ static int mnt_parse_mountinfo_line(stru
57 unsigned int maj, min;
58 char *fstype = NULL, *src = NULL, *p;
59
60 +#ifndef HAVE_SCANF_MS_MODIFIER
61 + size_t len = strlen(s) + 1;
62 + fs->root = malloc(len);
63 + fs->target = malloc(len);
64 + fs->vfs_optstr = malloc(len);
65 + fs->fs_optstr = malloc(len);
66 + fstype = malloc(len);
67 + src = malloc(len);
68 +#endif
69 +
70 rc = sscanf(s, "%d " /* (1) id */
71 "%d " /* (2) parent */
72 "%u:%u " /* (3) maj:min */
73 @@ -138,9 +167,15 @@ static int mnt_parse_mountinfo_line(stru
74 &fs->id,
75 &fs->parent,
76 &maj, &min,
77 +#ifdef HAVE_SCANF_MS_MODIFIER
78 &fs->root,
79 &fs->target,
80 &fs->vfs_optstr,
81 +#else
82 + fs->root,
83 + fs->target,
84 + fs->vfs_optstr,
85 +#endif
86 &end);
87
88 if (rc >= 7 && end > 0)
89 @@ -160,9 +195,15 @@ static int mnt_parse_mountinfo_line(stru
90 UL_SCNsA" " /* (9) source */
91 UL_SCNsA, /* (10) fs options (fs specific) */
92
93 +#ifdef HAVE_SCANF_MS_MODIFIER
94 &fstype,
95 &src,
96 &fs->fs_optstr);
97 +#else
98 + fstype,
99 + src,
100 + fs->fs_optstr);
101 +#endif
102
103 if (rc >= 10) {
104 size_t sz;