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
=== modified file 'hipd/dh.c'
--- hipd/dh.c 2010-10-15 15:29:14 +0000
+++ hipd/dh.c 2010-11-01 16:13:50 +0000
@@ -40,6 +40,15 @@
40#include "lib/core/debug.h"40#include "lib/core/debug.h"
41#include "dh.h"41#include "dh.h"
4242
43/**
44 * This table holds Diffie-Hellman values used during HIP BEXs.
45 * These values are generated when the HIP daemon starts and valid for its
46 * lifetime.
47 * Each array element corresponds to a DH value of a specific DH group.
48 * The valid groups are defined in RFC 5201, section 5.2.6.
49 * This array is indexed by the Group ID value defined in the RFC.
50 * Note that this means that the array element at index 0 is thus unused.
51 */
43DH *dh_table[HIP_MAX_DH_GROUP_ID] = {0};52DH *dh_table[HIP_MAX_DH_GROUP_ID] = {0};
4453
45/**54/**
@@ -53,6 +62,12 @@
53 int res;62 int res;
54 DH *tmp;63 DH *tmp;
5564
65 if (group_id <= 0 || group_id >= HIP_MAX_DH_GROUP_ID) {
66 HIP_ERROR("The Group ID %d is invalid\n", group_id);
67 res = -1;
68 goto err_free;
69 }
70
56 /*71 /*
57 * First check that we have the key available.72 * First check that we have the key available.
58 * Then encode it into the buffer73 * Then encode it into the buffer
@@ -105,6 +120,11 @@
105 int err = 0;120 int err = 0;
106 DH *tmp;121 DH *tmp;
107122
123 if (group_id <= 0 || group_id >= HIP_MAX_DH_GROUP_ID) {
124 HIP_ERROR("The Group ID %d is invalid\n", group_id);
125 return -1;
126 }
127
108 /*128 /*
109 * First check that we have the key available.129 * First check that we have the key available.
110 * Then encode it into the buffer130 * Then encode it into the buffer
@@ -146,7 +166,7 @@
146 maxmask = (1 << (HIP_MAX_DH_GROUP_ID + 1)) - 1;166 maxmask = (1 << (HIP_MAX_DH_GROUP_ID + 1)) - 1;
147 bitmask &= maxmask;167 bitmask &= maxmask;
148168
149 for (i = 1; i <= HIP_MAX_DH_GROUP_ID; i++) {169 for (i = 1; i < HIP_MAX_DH_GROUP_ID; i++) {
150 if (bitmask & (1 << i)) {170 if (bitmask & (1 << i)) {
151 tmp = hip_generate_dh_key(i);171 tmp = hip_generate_dh_key(i);
152 if (!tmp) {172 if (!tmp) {

Subscribers

People subscribed via source and target branches

to all changes: