summaryrefslogtreecommitdiff
path: root/source/a/shadow/patches/r3060.diff
blob: 8ece643000f079ba9162e3ba130b6a5cd31a72f5 (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
* libmisc/copydir.c, lib/shadowmem.c, lib/groupmem.c, lib/pwmem.c:
Fix some memory leaks.

Index: libmisc/copydir.c
===================================================================
--- libmisc/copydir.c	(revision 3059)
+++ libmisc/copydir.c	(revision 3060)
@@ -443,6 +443,7 @@
 		nchars = readlink (filename, buffer, size);
 
 		if (nchars < 0) {
+			free(buffer);
 			return NULL;
 		}
 

Index: lib/shadowmem.c
===================================================================
--- lib/shadowmem.c	(revision 3059)
+++ lib/shadowmem.c	(revision 3060)
@@ -52,10 +52,13 @@
 	*sp = *spent;
 	sp->sp_namp = strdup (spent->sp_namp);
 	if (NULL == sp->sp_namp) {
+		free(sp);
 		return NULL;
 	}
 	sp->sp_pwdp = strdup (spent->sp_pwdp);
 	if (NULL == sp->sp_pwdp) {
+		free(sp->sp_namp);
+		free(sp);
 		return NULL;
 	}
 
Index: lib/groupmem.c
===================================================================
--- lib/groupmem.c	(revision 3059)
+++ lib/groupmem.c	(revision 3060)
@@ -51,10 +51,13 @@
 	*gr = *grent;
 	gr->gr_name = strdup (grent->gr_name);
 	if (NULL == gr->gr_name) {
+		free(gr);
 		return NULL;
 	}
 	gr->gr_passwd = strdup (grent->gr_passwd);
 	if (NULL == gr->gr_passwd) {
+		free(gr->gr_name);
+		free(gr);
 		return NULL;
 	}
 
@@ -62,11 +65,21 @@
 
 	gr->gr_mem = (char **) malloc ((i + 1) * sizeof (char *));
 	if (NULL == gr->gr_mem) {
+		free(gr->gr_passwd);
+		free(gr->gr_name);
+		free(gr);
 		return NULL;
 	}
 	for (i = 0; grent->gr_mem[i]; i++) {
 		gr->gr_mem[i] = strdup (grent->gr_mem[i]);
 		if (NULL == gr->gr_mem[i]) {
+			int j;
+			for (j=0; j<i; j++)
+				free(gr->gr_mem[j]);
+			free(gr->gr_mem);
+			free(gr->gr_passwd);
+			free(gr->gr_name);
+			free(gr);
 			return NULL;
 		}
 	}
Index: lib/pwmem.c
===================================================================
--- lib/pwmem.c	(revision 3059)
+++ lib/pwmem.c	(revision 3060)
@@ -51,22 +51,37 @@
 	*pw = *pwent;
 	pw->pw_name = strdup (pwent->pw_name);
 	if (NULL == pw->pw_name) {
+		free(pw);
 		return NULL;
 	}
 	pw->pw_passwd = strdup (pwent->pw_passwd);
 	if (NULL == pw->pw_passwd) {
+		free(pw->pw_name);
+		free(pw);
 		return NULL;
 	}
 	pw->pw_gecos = strdup (pwent->pw_gecos);
 	if (NULL == pw->pw_gecos) {
+		free(pw->pw_passwd);
+		free(pw->pw_name);
+		free(pw);
 		return NULL;
 	}
 	pw->pw_dir = strdup (pwent->pw_dir);
 	if (NULL == pw->pw_dir) {
+		free(pw->pw_gecos);
+		free(pw->pw_passwd);
+		free(pw->pw_name);
+		free(pw);
 		return NULL;
 	}
 	pw->pw_shell = strdup (pwent->pw_shell);
 	if (NULL == pw->pw_shell) {
+		free(pw->pw_dir);
+		free(pw->pw_gecos);
+		free(pw->pw_passwd);
+		free(pw->pw_name);
+		free(pw);
 		return NULL;
 	}