-fixed route_new_list() not init. realloc'ed chunk bug, found by
Bogdan Pintea <bogdan.pintea@iptel.org>
... | ... |
@@ -823,7 +823,7 @@ again: |
823 | 823 |
if (n!=SIGIO){ |
824 | 824 |
#ifdef SIGINFO64_WORKARROUND |
825 | 825 |
/* on linux siginfo.si_band is defined as long in userspace |
826 |
- * and as int kernel => on 64 bits things will break! |
|
826 |
+ * and as int kernel (< 2.6.5) => on 64 bits things will break! |
|
827 | 827 |
* (si_band will include si_fd, and si_fd will contain |
828 | 828 |
* garbage) |
829 | 829 |
* see /usr/src/linux/include/asm-generic/siginfo.h and |
... | ... |
@@ -204,6 +204,8 @@ static inline int route_new_list(struct route_list* rt) |
204 | 204 |
LOG(L_CRIT, "ERROR: route_new_list: out of memory\n"); |
205 | 205 |
goto end; |
206 | 206 |
} |
207 |
+ /* init the newly allocated memory chunk */ |
|
208 |
+ memset(&tmp[rt->entries], 0, rt->entries*sizeof(struct action*)); |
|
207 | 209 |
rt->rlist=tmp; |
208 | 210 |
rt->entries*=2; |
209 | 211 |
} |
... | ... |
@@ -248,6 +250,28 @@ error: |
248 | 250 |
|
249 | 251 |
|
250 | 252 |
|
253 |
+/* |
|
254 |
+ * if the "name" route already exists, return its index, else |
|
255 |
+ * return error |
|
256 |
+ * return route index in rt->rlist or -1 on error |
|
257 |
+ */ |
|
258 |
+int route_lookup(struct route_list* rt, char* name) |
|
259 |
+{ |
|
260 |
+ int len; |
|
261 |
+ struct str_hash_entry* e; |
|
262 |
+ |
|
263 |
+ len=strlen(name); |
|
264 |
+ /* check if exists an non empty*/ |
|
265 |
+ e=str_hash_get(&rt->names, name, len); |
|
266 |
+ if (e){ |
|
267 |
+ return e->u.n; |
|
268 |
+ }else{ |
|
269 |
+ return -1; |
|
270 |
+ } |
|
271 |
+} |
|
272 |
+ |
|
273 |
+ |
|
274 |
+ |
|
251 | 275 |
static int fix_actions(struct action* a); /*fwd declaration*/ |
252 | 276 |
|
253 | 277 |
|
... | ... |
@@ -62,6 +62,7 @@ extern struct route_list onsend_rt; |
62 | 62 |
int init_routes(); |
63 | 63 |
void destroy_routes(); |
64 | 64 |
int route_get(struct route_list* rt, char* name); |
65 |
+int route_lookup(struct route_list* rt, char* name); |
|
65 | 66 |
|
66 | 67 |
void push(struct action* a, struct action** head); |
67 | 68 |
int add_actions(struct action* a, struct action** head); |