summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/insserv/files/40_segfault_virtprov.dpatch
blob: 9b0081307afd91d383af8ebed272e6acf8d859eb (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
#! /bin/sh /usr/share/dpatch/dpatch-run
## 40_segfault_virtprov.dpatch by Petter Reinholdtsen

Avoid segfault when an enabled service provide a virtual system
facility.

@DPATCH@
--- insserv/insserv.c
+++ insserv/insserv.c	2008-02-01 11:43:45.634618329 +0100
@@ -166,7 +166,7 @@ typedef struct pwd_struct {
 
 static list_t pwd = { &(pwd), &(pwd) }, * topd = &(pwd);
 
-static void pushd(const char *const __restrict path);
+static void pushd(const char *const __restrict path) __attribute__((nonnull(1)));
 static void pushd(const char *const path)
 {
     pwd_t *  dir;
@@ -305,13 +305,13 @@ out:
     return getserv(ptr);
 }
 
-static serv_t * findserv(const char *const __restrict serv) __attribute__((nonnull(1)));
+static serv_t * findserv(const char *const __restrict serv);
 static serv_t * findserv(const char *const serv)
 {
     list_t * ptr;
     serv_t * ret = (serv_t*)0;
 
-    if (!serv)
+    if (serv == (const char*)0)
 	goto out;
 
     list_for_each(ptr, serv_start) {
@@ -334,6 +334,9 @@ static void rememberreq(serv_t *serv, ui
     list_t * ptr;
     uint old = bit;
 
+    if (!tmp)
+	error("%s", strerror(errno));
+
     while ((token = strsep(&tmp, delimeter))) {
 	boolean found = false;
 	req_t * this;
@@ -399,6 +402,9 @@ static void reversereq(const serv_t * se
     char * rev = strdupa(list);
     uint old = bit;
 
+    if (!rev)
+	error("%s", strerror(errno));
+
     while ((dep = strsep(&rev, delimeter)) && *dep) {
 	serv_t * tmp;
 	list_t * ptr;
@@ -437,7 +443,7 @@ static void reversereq(const serv_t * se
 /*
  * Check required services for name
  */
-static boolean chkrequired(const char *const __restrict name) __attribute__((nonnull(1)));
+static boolean chkrequired(const char *const __restrict name);
 static boolean chkrequired(const char *const name)
 {
     serv_t * serv = findserv(name);
--- insserv/listing.h
+++ insserv/listing.h	2008-02-01 11:40:45.347748072 +0100
@@ -97,11 +97,11 @@ extern int makeprov(const char *__restri
 extern void setorder(const char *__restrict script, const int order, boolean recursive) __attribute__((nonnull(1)));
 extern int getorder(const char *__restrict script) __attribute__((nonnull(1)));
 extern boolean notincluded(const char *__restrict script, const int runlevel) __attribute__((nonnull(1)));
-extern boolean foreach(const char **__restrict script, int *__restrict order, const int runlevel) __attribute__((nonnull(1,2)));
-extern void virtprov(const char *__restrict virt, const char *__restrict real) __attribute__((nonnull(1,2)));
+extern boolean foreach(const char **__restrict script, int *__restrict order, const int runlevel) __attribute__((nonnull(2)));
+extern void virtprov(const char *__restrict virt, const char *__restrict real) __attribute__((nonnull(1)));
 extern const char * getscript(const char *__restrict prov) __attribute__((nonnull(1)));
 extern const char * getprovides(const char *__restrict script) __attribute__((nonnull(1)));
-extern boolean listscripts(const char **__restrict script, const int lvl) __attribute__((nonnull(1)));
+extern boolean listscripts(const char **__restrict script, const int lvl);
 extern int maxorder;
 extern boolean is_loop_detected(void);
 
@@ -116,7 +116,7 @@ extern int map_has_runlevels(void);
 extern int map_runlevel_to_lvl (const int runlevel);
 extern int map_key_to_lvl(const char key);
 
-static inline char * xstrdup(const char *__restrict s) __attribute__((always_inline,nonnull(1)));
+static inline char * xstrdup(const char *__restrict s) __attribute__((always_inline));
 static inline char * xstrdup(const char * s)
 {
     char * r;