diff options
Diffstat (limited to 'meta/recipes-support/attr/attr-2.4.44/memory-leak-in-copy.patch')
-rw-r--r-- | meta/recipes-support/attr/attr-2.4.44/memory-leak-in-copy.patch | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/meta/recipes-support/attr/attr-2.4.44/memory-leak-in-copy.patch b/meta/recipes-support/attr/attr-2.4.44/memory-leak-in-copy.patch new file mode 100644 index 0000000000..966632d87e --- /dev/null +++ b/meta/recipes-support/attr/attr-2.4.44/memory-leak-in-copy.patch | |||
@@ -0,0 +1,50 @@ | |||
1 | commit 972b42a67393f762936e74d3ce929914181f5f28 | ||
2 | Author: Brandon Philips <brandon@ifup.org> | ||
3 | Date: Thu Dec 17 17:15:57 2009 -0800 | ||
4 | |||
5 | libattr: fix memory leak in attr_copy_action() | ||
6 | |||
7 | stanse found that attr_copy_action returns before freeing the memory | ||
8 | allocated for text. | ||
9 | |||
10 | Move fopen() above the malloc so this is not a problem. | ||
11 | |||
12 | Fixes this bug: | ||
13 | https://bugzilla.novell.com/show_bug.cgi?id=564735 | ||
14 | |||
15 | Signed-off-by: Brandon Philips <bphilips@suse.de> | ||
16 | |||
17 | diff --git a/libattr/attr_copy_action.c b/libattr/attr_copy_action.c | ||
18 | index 0d7aca5..dc94224 100644 | ||
19 | --- a/libattr/attr_copy_action.c | ||
20 | +++ b/libattr/attr_copy_action.c | ||
21 | @@ -53,7 +53,7 @@ free_attr_actions(void) | ||
22 | static int | ||
23 | attr_parse_attr_conf(struct error_context *ctx) | ||
24 | { | ||
25 | - char *text, *t; | ||
26 | + char *text = NULL, *t; | ||
27 | size_t size_guess = 4096, len; | ||
28 | FILE *file; | ||
29 | char *pattern = NULL; | ||
30 | @@ -64,15 +64,16 @@ attr_parse_attr_conf(struct error_context *ctx) | ||
31 | return 0; | ||
32 | |||
33 | repeat: | ||
34 | - text = malloc(size_guess + 1); | ||
35 | - if (!text) | ||
36 | - goto fail; | ||
37 | - | ||
38 | if ((file = fopen(ATTR_CONF, "r")) == NULL) { | ||
39 | if (errno == ENOENT) | ||
40 | return 0; | ||
41 | goto fail; | ||
42 | } | ||
43 | + | ||
44 | + text = malloc(size_guess + 1); | ||
45 | + if (!text) | ||
46 | + goto fail; | ||
47 | + | ||
48 | len = fread(text, 1, size_guess, file); | ||
49 | if (ferror(file)) | ||
50 | goto fail; | ||