Merge lp:~oif-team/geis/clone-fix into lp:geis

Proposed by Chase Douglas
Status: Merged
Merged at revision: 124
Proposed branch: lp:~oif-team/geis/clone-fix
Merge into: lp:geis
Diff against target: 66 lines (+8/-6)
3 files modified
libutouch-geis/geis_filter.c (+1/-1)
libutouch-geis/geis_filter_term.c (+3/-4)
libutouch-geis/geis_filter_term.h (+4/-1)
To merge this branch: bzr merge lp:~oif-team/geis/clone-fix
Reviewer Review Type Date Requested Status
Stephen M. Webb (community) Approve
Review via email: mp+54562@code.launchpad.net

Description of the change

Fix buffer overflow when cloning filter bags

To post a comment you must log in.
Revision history for this message
Stephen M. Webb (bregma) wrote :

geis_filter_term_bag_new() should take a GeisSize argument instead of unsigned int for consistency.

With that change, I approve.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libutouch-geis/geis_filter.c'
2--- libutouch-geis/geis_filter.c 2011-02-27 21:41:00 +0000
3+++ libutouch-geis/geis_filter.c 2011-03-23 16:46:33 +0000
4@@ -250,7 +250,7 @@
5 goto final_exit;
6 }
7
8- filter->terms = geis_filter_term_bag_new();
9+ filter->terms = geis_filter_term_bag_new(0);
10 if (!filter->terms)
11 {
12 geis_error_push(geis, GEIS_STATUS_UNKNOWN_ERROR);
13
14=== modified file 'libutouch-geis/geis_filter_term.c'
15--- libutouch-geis/geis_filter_term.c 2011-02-27 21:41:00 +0000
16+++ libutouch-geis/geis_filter_term.c 2011-03-23 16:46:33 +0000
17@@ -54,7 +54,7 @@
18
19
20 GeisFilterTermBag
21-geis_filter_term_bag_new()
22+geis_filter_term_bag_new(unsigned int store_size)
23 {
24 GeisFilterTermBag bag = calloc(1, sizeof(struct _GeisFilterTermBag));
25 if (!bag)
26@@ -63,7 +63,7 @@
27 goto final_exit;
28 }
29
30- bag->store_size = 3;
31+ bag->store_size = store_size ? store_size : 3;
32 bag->count = 0;
33 bag->store = calloc(bag->store_size, sizeof(GeisFilterTerm));
34 if (!bag->store)
35@@ -88,13 +88,12 @@
36 geis_filter_term_bag_clone(GeisFilterTermBag original)
37 {
38 GeisSize i;
39- GeisFilterTermBag bag = geis_filter_term_bag_new();
40+ GeisFilterTermBag bag = geis_filter_term_bag_new(original->store_size);
41 if (!bag)
42 {
43 goto final_exit;
44 }
45
46- bag->store_size = original->store_size;
47 bag->count = original->count;
48 for (i = 0; i < bag->count; ++i)
49 {
50
51=== modified file 'libutouch-geis/geis_filter_term.h'
52--- libutouch-geis/geis_filter_term.h 2011-02-17 17:40:49 +0000
53+++ libutouch-geis/geis_filter_term.h 2011-03-23 16:46:33 +0000
54@@ -105,8 +105,11 @@
55
56 /**
57 * Creates a new, empty filter term bag,
58+ *
59+ * @param[in] store_size The initial filter store size. A value of 0 will
60+ * allocate a reasonable default size.
61 */
62-GeisFilterTermBag geis_filter_term_bag_new();
63+GeisFilterTermBag geis_filter_term_bag_new(unsigned int store_size);
64
65 /**
66 * Creates a new filter term bag by deep-copying an existing filter term bag.

Subscribers

People subscribed via source and target branches

to all changes: