Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
iproute2
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
iproute2
Commits
38c867d2
Commit
38c867d2
authored
Mar 09, 2011
by
Stephen Hemminger
Committed by
Stephen Hemminger
Apr 12, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add checks for fgets() when reading proc
If expected proc headers are missing, catch and print error.
parent
46dc73a5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
7 deletions
+17
-7
ip/ip6tunnel.c
ip/ip6tunnel.c
+5
-2
ip/ipmaddr.c
ip/ipmaddr.c
+2
-1
ip/ipmroute.c
ip/ipmroute.c
+4
-2
ip/iptunnel.c
ip/iptunnel.c
+6
-2
No files found.
ip/ip6tunnel.c
View file @
38c867d2
...
@@ -262,8 +262,11 @@ static int do_tunnels_list(struct ip6_tnl_parm *p)
...
@@ -262,8 +262,11 @@ static int do_tunnels_list(struct ip6_tnl_parm *p)
}
}
/* skip two lines at the begenning of the file */
/* skip two lines at the begenning of the file */
fgets
(
buf
,
sizeof
(
buf
),
fp
);
if
(
!
fgets
(
buf
,
sizeof
(
buf
),
fp
)
||
fgets
(
buf
,
sizeof
(
buf
),
fp
);
!
fgets
(
buf
,
sizeof
(
buf
),
fp
))
{
fprintf
(
stderr
,
"/proc/net/dev read error
\n
"
);
return
-
1
;
}
while
(
fgets
(
buf
,
sizeof
(
buf
),
fp
)
!=
NULL
)
{
while
(
fgets
(
buf
,
sizeof
(
buf
),
fp
)
!=
NULL
)
{
char
name
[
IFNAMSIZ
];
char
name
[
IFNAMSIZ
];
...
...
ip/ipmaddr.c
View file @
38c867d2
...
@@ -128,7 +128,8 @@ void read_igmp(struct ma_info **result_p)
...
@@ -128,7 +128,8 @@ void read_igmp(struct ma_info **result_p)
if
(
!
fp
)
if
(
!
fp
)
return
;
return
;
memset
(
&
m
,
0
,
sizeof
(
m
));
memset
(
&
m
,
0
,
sizeof
(
m
));
fgets
(
buf
,
sizeof
(
buf
),
fp
);
if
(
!
fgets
(
buf
,
sizeof
(
buf
),
fp
))
return
;
m
.
addr
.
family
=
AF_INET
;
m
.
addr
.
family
=
AF_INET
;
m
.
addr
.
bitlen
=
32
;
m
.
addr
.
bitlen
=
32
;
...
...
ip/ipmroute.c
View file @
38c867d2
...
@@ -58,7 +58,8 @@ static void read_viftable(void)
...
@@ -58,7 +58,8 @@ static void read_viftable(void)
if
(
!
fp
)
if
(
!
fp
)
return
;
return
;
fgets
(
buf
,
sizeof
(
buf
),
fp
);
if
(
!
fgets
(
buf
,
sizeof
(
buf
),
fp
))
return
;
while
(
fgets
(
buf
,
sizeof
(
buf
),
fp
))
{
while
(
fgets
(
buf
,
sizeof
(
buf
),
fp
))
{
int
vifi
;
int
vifi
;
...
@@ -83,7 +84,8 @@ static void read_mroute_list(FILE *ofp)
...
@@ -83,7 +84,8 @@ static void read_mroute_list(FILE *ofp)
if
(
!
fp
)
if
(
!
fp
)
return
;
return
;
fgets
(
buf
,
sizeof
(
buf
),
fp
);
if
(
!
fgets
(
buf
,
sizeof
(
buf
),
fp
))
return
;
while
(
fgets
(
buf
,
sizeof
(
buf
),
fp
))
{
while
(
fgets
(
buf
,
sizeof
(
buf
),
fp
))
{
inet_prefix
maddr
,
msrc
;
inet_prefix
maddr
,
msrc
;
...
...
ip/iptunnel.c
View file @
38c867d2
...
@@ -407,8 +407,12 @@ static int do_tunnels_list(struct ip_tunnel_parm *p)
...
@@ -407,8 +407,12 @@ static int do_tunnels_list(struct ip_tunnel_parm *p)
return
-
1
;
return
-
1
;
}
}
fgets
(
buf
,
sizeof
(
buf
),
fp
);
/* skip header lines */
fgets
(
buf
,
sizeof
(
buf
),
fp
);
if
(
!
fgets
(
buf
,
sizeof
(
buf
),
fp
)
||
!
fgets
(
buf
,
sizeof
(
buf
),
fp
))
{
fprintf
(
stderr
,
"/proc/net/dev read error
\n
"
);
return
-
1
;
}
while
(
fgets
(
buf
,
sizeof
(
buf
),
fp
)
!=
NULL
)
{
while
(
fgets
(
buf
,
sizeof
(
buf
),
fp
)
!=
NULL
)
{
int
index
,
type
;
int
index
,
type
;
...
...
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