aboutsummaryrefslogtreecommitdiff
path: root/package/util-linux/util-linux-001-sscanf-no-ms-as.patch
blob: be2b0eb269bd9028cca045d6e4a1a0b09117ba4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
Fix libmount build under uClibc

See https://bugs.gentoo.org/show_bug.cgi?id=406303
http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-apps/util-linux/files/util-linux-2.21.1-no-printf-alloc.patch?revision=1.2

[Gustavo: Ported to util-linux-2.25.1]

Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>

diff -Nura util-linux-2.25.1.orig/configure.ac util-linux-2.25.1/configure.ac
--- util-linux-2.25.1.orig/configure.ac	2014-09-05 10:44:45.302080174 -0300
+++ util-linux-2.25.1/configure.ac	2014-09-05 10:45:07.183832640 -0300
@@ -791,7 +791,6 @@
 UL_BUILD_INIT([libmount])
 UL_REQUIRES_LINUX([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])
 
diff -Nura util-linux-2.25.1.orig/lib/colors.c util-linux-2.25.1/lib/colors.c
--- util-linux-2.25.1.orig/lib/colors.c	2014-09-05 10:44:45.301080140 -0300
+++ util-linux-2.25.1/lib/colors.c	2014-09-05 13:12:00.175205476 -0300
@@ -16,6 +16,10 @@
 #include "pathnames.h"
 #include "strutils.h"
 
+#ifndef HAVE_SCANF_MS_MODIFIER
+# define UL_SCNsA "%s"
+#endif
+
 /*
  * terminal-colors.d file types
  */
@@ -577,9 +581,19 @@
 		if (*p == '\0' || *p == '#')
 			continue;
 
+#ifndef HAVE_SCANF_MS_MODIFIER
+		size_t len = strlen(p) + 1;
+		cn = malloc(len);
+		seq = malloc(len);
+#endif
+
 		rc = sscanf(p,  UL_SCNsA" "	/* name */
 				UL_SCNsA,	/* color */
+#ifdef HAVE_SCANF_MS_MODIFIER
 				&cn, &seq);
+#else
+				cn, seq);
+#endif
 		if (rc == 2 && cn && seq)
 			rc = colors_add_scheme(cc, cn, seq);	/* set rc=0 on success */
 		if (rc) {
diff -Nura util-linux-2.25.1.orig/libmount/src/tab_parse.c util-linux-2.25.1/libmount/src/tab_parse.c
--- util-linux-2.25.1.orig/libmount/src/tab_parse.c	2014-09-05 10:44:45.276079280 -0300
+++ util-linux-2.25.1/libmount/src/tab_parse.c	2014-09-05 10:51:22.500738967 -0300
@@ -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 @@
 	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 @@
 	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 @@
 			&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 @@
 			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;
@@ -281,14 +322,25 @@
 	int rc;
 	char *src = NULL;
 
+#ifndef HAVE_SCANF_MS_MODIFIER
+	size_t len = strlen(s) + 1;
+	src = malloc(len);
+	fs->swaptype = malloc(len);
+#endif
+
 	rc = sscanf(s,	UL_SCNsA" "	/* (1) source */
 			UL_SCNsA" "	/* (2) type */
 			"%ju"		/* (3) size */
 			"%ju"		/* (4) used */
 			"%d",		/* priority */
 
+#ifdef HAVE_SCANF_MS_MODIFIER
 			&src,
 			&fs->swaptype,
+#else
+			src,
+			fs->swaptype,
+#endif
 			&fsz,
 			&usz,
 			&fs->priority);