Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
babeld
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
babeld
Commits
d1c82a6e
Commit
d1c82a6e
authored
May 19, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Realloc xroutes on table overflow.
This is safe, since no part of the code ever holds a pointer to an xroute.
parent
eade5273
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
5 deletions
+17
-5
babel.h
babel.h
+0
-1
xroute.c
xroute.c
+16
-3
xroute.h
xroute.h
+1
-1
No files found.
babel.h
View file @
d1c82a6e
...
@@ -23,7 +23,6 @@ THE SOFTWARE.
...
@@ -23,7 +23,6 @@ THE SOFTWARE.
#define MAXROUTES 512
#define MAXROUTES 512
#define MAXSRCS 256
#define MAXSRCS 256
#define MAXNEIGHBOURS 64
#define MAXNEIGHBOURS 64
#define MAXXROUTES 64
#define INFINITY ((unsigned short)(~0))
#define INFINITY ((unsigned short)(~0))
...
...
xroute.c
View file @
d1c82a6e
...
@@ -37,8 +37,9 @@ THE SOFTWARE.
...
@@ -37,8 +37,9 @@ THE SOFTWARE.
#include "filter.h"
#include "filter.h"
#include "network.h"
#include "network.h"
struct
xroute
xroutes
[
MAXXROUTES
]
;
struct
xroute
*
xroutes
;
int
numxroutes
=
0
;
int
numxroutes
=
0
;
int
maxxroutes
=
0
;
struct
xroute
*
struct
xroute
*
find_xroute
(
const
unsigned
char
*
prefix
,
unsigned
char
plen
)
find_xroute
(
const
unsigned
char
*
prefix
,
unsigned
char
plen
)
...
@@ -85,8 +86,20 @@ add_xroute(int kind, unsigned char prefix[16], unsigned char plen,
...
@@ -85,8 +86,20 @@ add_xroute(int kind, unsigned char prefix[16], unsigned char plen,
return
1
;
return
1
;
}
}
if
(
numxroutes
>=
MAXXROUTES
)
if
(
numxroutes
>=
maxxroutes
)
{
return
-
1
;
struct
xroute
*
new_xroutes
;
int
n
=
maxxroutes
<
1
?
8
:
2
*
maxxroutes
;
new_xroutes
=
xroutes
==
NULL
?
malloc
(
n
*
sizeof
(
struct
xroute
))
:
realloc
(
xroutes
,
n
*
sizeof
(
struct
xroute
));
if
(
new_xroutes
==
NULL
)
return
-
1
;
maxxroutes
=
n
;
xroutes
=
new_xroutes
;
}
xroutes
[
numxroutes
].
kind
=
kind
;
xroutes
[
numxroutes
].
kind
=
kind
;
memcpy
(
xroutes
[
numxroutes
].
prefix
,
prefix
,
16
);
memcpy
(
xroutes
[
numxroutes
].
prefix
,
prefix
,
16
);
...
...
xroute.h
View file @
d1c82a6e
...
@@ -34,7 +34,7 @@ struct xroute {
...
@@ -34,7 +34,7 @@ struct xroute {
int
proto
;
int
proto
;
};
};
extern
struct
xroute
xroutes
[
MAXXROUTES
]
;
extern
struct
xroute
*
xroutes
;
extern
int
numxroutes
;
extern
int
numxroutes
;
struct
xroute
*
find_xroute
(
const
unsigned
char
*
prefix
,
unsigned
char
plen
);
struct
xroute
*
find_xroute
(
const
unsigned
char
*
prefix
,
unsigned
char
plen
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment