Merge lp:~stefan.goetz-deactivatedaccount/hipl/dh-key-generation-fixes into lp:hipl

Proposed by Stefan Götz
Status: Merged
Merged at revision: 5133
Proposed branch: lp:~stefan.goetz-deactivatedaccount/hipl/dh-key-generation-fixes
Merge into: lp:hipl
Diff against target: 53 lines (+21/-1)
1 file modified
hipd/dh.c (+21/-1)
To merge this branch: bzr merge lp:~stefan.goetz-deactivatedaccount/hipl/dh-key-generation-fixes
Reviewer Review Type Date Requested Status
Miika Komu Approve
Review via email: mp+39757@code.launchpad.net

Description of the change

Fixes an out-of-bounds access to an array which prevented compiling HIPL at optimization level 3

To post a comment you must log in.
Revision history for this message
Miika Komu (miika-iki) wrote :

Tested and seems to work. Thanks Stefan!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hipd/dh.c'
2--- hipd/dh.c 2010-10-15 15:29:14 +0000
3+++ hipd/dh.c 2010-11-01 16:13:50 +0000
4@@ -40,6 +40,15 @@
5 #include "lib/core/debug.h"
6 #include "dh.h"
7
8+/**
9+ * This table holds Diffie-Hellman values used during HIP BEXs.
10+ * These values are generated when the HIP daemon starts and valid for its
11+ * lifetime.
12+ * Each array element corresponds to a DH value of a specific DH group.
13+ * The valid groups are defined in RFC 5201, section 5.2.6.
14+ * This array is indexed by the Group ID value defined in the RFC.
15+ * Note that this means that the array element at index 0 is thus unused.
16+ */
17 DH *dh_table[HIP_MAX_DH_GROUP_ID] = {0};
18
19 /**
20@@ -53,6 +62,12 @@
21 int res;
22 DH *tmp;
23
24+ if (group_id <= 0 || group_id >= HIP_MAX_DH_GROUP_ID) {
25+ HIP_ERROR("The Group ID %d is invalid\n", group_id);
26+ res = -1;
27+ goto err_free;
28+ }
29+
30 /*
31 * First check that we have the key available.
32 * Then encode it into the buffer
33@@ -105,6 +120,11 @@
34 int err = 0;
35 DH *tmp;
36
37+ if (group_id <= 0 || group_id >= HIP_MAX_DH_GROUP_ID) {
38+ HIP_ERROR("The Group ID %d is invalid\n", group_id);
39+ return -1;
40+ }
41+
42 /*
43 * First check that we have the key available.
44 * Then encode it into the buffer
45@@ -146,7 +166,7 @@
46 maxmask = (1 << (HIP_MAX_DH_GROUP_ID + 1)) - 1;
47 bitmask &= maxmask;
48
49- for (i = 1; i <= HIP_MAX_DH_GROUP_ID; i++) {
50+ for (i = 1; i < HIP_MAX_DH_GROUP_ID; i++) {
51 if (bitmask & (1 << i)) {
52 tmp = hip_generate_dh_key(i);
53 if (!tmp) {

Subscribers

People subscribed via source and target branches

to all changes: