Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
net-tools
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
net-tools
Commits
dc752cca
Commit
dc752cca
authored
Jun 13, 2013
by
Bernd
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1 from florianl/master
[PATCH] replace strcpy() with safe_strncpy()
parents
6a14c03f
3a2961de
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
13 deletions
+13
-13
lib/net-support.h
lib/net-support.h
+1
-1
netstat.c
netstat.c
+12
-12
No files found.
lib/net-support.h
View file @
dc752cca
...
@@ -137,7 +137,7 @@ extern int flag_inet;
...
@@ -137,7 +137,7 @@ extern int flag_inet;
extern
int
flag_inet6
;
extern
int
flag_inet6
;
extern
int
flag_bluetooth
;
extern
int
flag_bluetooth
;
extern
char
afname
[];
extern
char
afname
[
256
];
#define AFTRANS_OPTS \
#define AFTRANS_OPTS \
{"ax25", 0, 0, 1}, \
{"ax25", 0, 0, 1}, \
...
...
netstat.c
View file @
dc752cca
...
@@ -294,16 +294,14 @@ static void prg_cache_add(unsigned long inode, char *name, const char *scon)
...
@@ -294,16 +294,14 @@ static void prg_cache_add(unsigned long inode, char *name, const char *scon)
pn
=
*
pnp
;
pn
=
*
pnp
;
pn
->
next
=
NULL
;
pn
->
next
=
NULL
;
pn
->
inode
=
inode
;
pn
->
inode
=
inode
;
if
(
strlen
(
name
)
>
sizeof
(
pn
->
name
)
-
1
)
safe_strncpy
(
pn
->
name
,
name
,
sizeof
(
pn
->
name
));
name
[
sizeof
(
pn
->
name
)
-
1
]
=
'\0'
;
strcpy
(
pn
->
name
,
name
);
{
{
int
len
=
(
strlen
(
scon
)
-
sizeof
(
pn
->
scon
))
+
1
;
int
len
=
(
strlen
(
scon
)
-
sizeof
(
pn
->
scon
))
+
1
;
if
(
len
>
0
)
if
(
len
>
0
)
s
trcpy
(
pn
->
scon
,
&
scon
[
len
+
1
]
);
s
afe_strncpy
(
pn
->
scon
,
&
scon
[
len
+
1
],
sizeof
(
pn
->
scon
)
);
else
else
s
trcpy
(
pn
->
scon
,
scon
);
s
afe_strncpy
(
pn
->
scon
,
scon
,
sizeof
(
pn
->
scon
)
);
}
}
}
}
...
@@ -441,7 +439,8 @@ static void prg_cache_load(void)
...
@@ -441,7 +439,8 @@ static void prg_cache_load(void)
continue
;
continue
;
memcpy
(
line
+
procfdlen
-
PATH_FD_SUFFl
,
PATH_FD_SUFF
"/"
,
memcpy
(
line
+
procfdlen
-
PATH_FD_SUFFl
,
PATH_FD_SUFF
"/"
,
PATH_FD_SUFFl
+
1
);
PATH_FD_SUFFl
+
1
);
strcpy
(
line
+
procfdlen
+
1
,
direfd
->
d_name
);
safe_strncpy
(
line
+
procfdlen
+
1
,
direfd
->
d_name
,
sizeof
(
line
)
-
procfdlen
-
1
);
lnamelen
=
readlink
(
line
,
lname
,
sizeof
(
lname
)
-
1
);
lnamelen
=
readlink
(
line
,
lname
,
sizeof
(
lname
)
-
1
);
if
(
lnamelen
==
-
1
)
if
(
lnamelen
==
-
1
)
continue
;
continue
;
...
@@ -455,7 +454,8 @@ static void prg_cache_load(void)
...
@@ -455,7 +454,8 @@ static void prg_cache_load(void)
if
(
procfdlen
-
PATH_FD_SUFFl
+
PATH_CMDLINEl
>=
if
(
procfdlen
-
PATH_FD_SUFFl
+
PATH_CMDLINEl
>=
sizeof
(
line
)
-
5
)
sizeof
(
line
)
-
5
)
continue
;
continue
;
strcpy
(
line
+
procfdlen
-
PATH_FD_SUFFl
,
PATH_CMDLINE
);
safe_strncpy
(
line
+
procfdlen
-
PATH_FD_SUFFl
,
PATH_CMDLINE
,
sizeof
(
line
)
-
procfdlen
+
PATH_FD_SUFFl
);
fd
=
open
(
line
,
O_RDONLY
);
fd
=
open
(
line
,
O_RDONLY
);
if
(
fd
<
0
)
if
(
fd
<
0
)
continue
;
continue
;
...
@@ -1399,7 +1399,7 @@ static void unix_do_one(int nr, const char *line, const char *prot)
...
@@ -1399,7 +1399,7 @@ static void unix_do_one(int nr, const char *line, const char *prot)
ss_state
=
_
(
"UNKNOWN"
);
ss_state
=
_
(
"UNKNOWN"
);
}
}
s
trcpy
(
ss_flags
,
"[ "
);
s
afe_strncpy
(
ss_flags
,
"[ "
,
sizeof
(
ss_flags
)
);
if
(
flags
&
SO_ACCEPTCON
)
if
(
flags
&
SO_ACCEPTCON
)
strcat
(
ss_flags
,
"ACC "
);
strcat
(
ss_flags
,
"ACC "
);
if
(
flags
&
SO_WAITDATA
)
if
(
flags
&
SO_WAITDATA
)
...
@@ -1653,7 +1653,7 @@ static int ipx_info(void)
...
@@ -1653,7 +1653,7 @@ static int ipx_info(void)
safe_strncpy
(
buf
,
ap
->
sprint
(
&
sa
,
flag_not
&
FLAG_NUM_HOST
),
sizeof
(
buf
));
safe_strncpy
(
buf
,
ap
->
sprint
(
&
sa
,
flag_not
&
FLAG_NUM_HOST
),
sizeof
(
buf
));
snprintf
(
dad
,
sizeof
(
dad
),
"%s:%04X"
,
buf
,
dport
);
snprintf
(
dad
,
sizeof
(
dad
),
"%s:%04X"
,
buf
,
dport
);
}
else
}
else
strcpy
(
dad
,
"-"
);
safe_strncpy
(
dad
,
"-"
,
sizeof
(
dad
)
);
printf
(
"IPX %6ld %6ld %-26s %-26s %-5s"
,
txq
,
rxq
,
sad
,
dad
,
st
);
printf
(
"IPX %6ld %6ld %-26s %-26s %-5s"
,
txq
,
rxq
,
sad
,
dad
,
st
);
if
(
flag_exp
>
1
)
{
if
(
flag_exp
>
1
)
{
...
@@ -2065,7 +2065,7 @@ int main
...
@@ -2065,7 +2065,7 @@ int main
#if HAVE_FW_MASQUERADE && HAVE_AFINET
#if HAVE_FW_MASQUERADE && HAVE_AFINET
#if MORE_THAN_ONE_MASQ_AF
#if MORE_THAN_ONE_MASQ_AF
if
(
!
afname
[
0
])
if
(
!
afname
[
0
])
strcpy
(
afname
,
DFLT_AF
);
safe_strncpy
(
afname
,
DFLT_AF
,
sizeof
(
afname
)
);
#endif
#endif
for
(;;)
{
for
(;;)
{
i
=
ip_masq_info
(
flag_not
&
FLAG_NUM_HOST
,
i
=
ip_masq_info
(
flag_not
&
FLAG_NUM_HOST
,
...
@@ -2083,7 +2083,7 @@ int main
...
@@ -2083,7 +2083,7 @@ int main
if
(
flag_sta
)
{
if
(
flag_sta
)
{
if
(
!
afname
[
0
])
if
(
!
afname
[
0
])
s
trcpy
(
afname
,
DFLT_AF
);
s
afe_strncpy
(
afname
,
DFLT_AF
,
sizeof
(
afname
)
);
if
(
!
strcmp
(
afname
,
"inet"
))
{
if
(
!
strcmp
(
afname
,
"inet"
))
{
#if HAVE_AFINET
#if HAVE_AFINET
...
@@ -2110,7 +2110,7 @@ int main
...
@@ -2110,7 +2110,7 @@ int main
int
options
=
0
;
int
options
=
0
;
if
(
!
afname
[
0
])
if
(
!
afname
[
0
])
strcpy
(
afname
,
DFLT_AF
);
safe_strncpy
(
afname
,
DFLT_AF
,
sizeof
(
afname
)
);
if
(
flag_exp
==
2
)
if
(
flag_exp
==
2
)
flag_exp
=
1
;
flag_exp
=
1
;
...
...
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