Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Main
Synchronet
Commits
53985a6b
Commit
53985a6b
authored
Feb 20, 2018
by
rswindell
Browse files
Address Coverity-reported resource leaks.
parent
ca8a419b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
43 deletions
+50
-43
src/sbbs3/fido.cpp
src/sbbs3/fido.cpp
+33
-28
src/sbbs3/file.cpp
src/sbbs3/file.cpp
+1
-0
src/sbbs3/filedat.c
src/sbbs3/filedat.c
+16
-15
No files found.
src/sbbs3/fido.cpp
View file @
53985a6b
...
...
@@ -111,12 +111,18 @@ bool sbbs_t::netmail(const char *into, const char *title, long mode)
uint
i
;
long
length
,
l
;
faddr_t
addr
;
uint16_t
net_type
;
fmsghdr_t
hdr
;
struct
tm
tm
;
if
(
useron
.
etoday
>=
cfg
.
level_emailperday
[
useron
.
level
]
&&
!
SYSOP
&&
!
(
useron
.
exempt
&
FLAG
(
'M'
)))
{
bputs
(
text
[
TooManyEmailsToday
]);
return
(
false
);
return
false
;
}
if
(
useron
.
rest
&
FLAG
(
'M'
))
{
bputs
(
text
[
NoNetMailAllowed
]);
return
false
;
}
SAFECOPY
(
subj
,
title
);
...
...
@@ -125,40 +131,39 @@ bool sbbs_t::netmail(const char *into, const char *title, long mode)
lookup_netuser
(
to
);
p
=
strrchr
(
to
,
'@'
);
/* Find '@' in name@addr */
if
(
p
&&
!
isdigit
(
*
(
p
+
1
))
&&
!
strchr
(
p
,
'.'
)
&&
!
strchr
(
p
,
':'
))
{
net_type
=
smb_netaddr_type
(
to
);
lprintf
(
LOG_DEBUG
,
"parsed net type of '%s' is %s
\r\n
"
,
to
,
smb_nettype
((
enum
smb_net_type
)
net_type
));
if
(
net_type
==
NET_QWK
)
{
mode
&=~
WM_FILE
;
qnetmail
(
to
,
title
,
mode
|
WM_NETMAIL
);
return
(
false
)
;
return
false
;
}
if
(
!
cfg
.
total_faddrs
||
p
==
NULL
||
!
strchr
(
p
+
1
,
'/'
))
{
if
(
!
p
&&
cfg
.
dflt_faddr
.
zone
)
addr
=
cfg
.
dflt_faddr
;
else
if
(
cfg
.
inetmail_misc
&
NMAIL_ALLOW
)
{
if
(
mode
&
WM_FILE
&&
!
SYSOP
&&
!
(
cfg
.
inetmail_misc
&
NMAIL_FILE
))
mode
&=~
WM_FILE
;
return
(
inetmail
(
into
,
title
,
mode
|
WM_NETMAIL
));
if
(
net_type
==
NET_INTERNET
)
{
if
(
!
(
cfg
.
inetmail_misc
&
NMAIL_ALLOW
))
{
bputs
(
text
[
NoNetMailAllowed
]);
return
false
;
}
else
if
(
cfg
.
dflt_faddr
.
zone
)
addr
=
cfg
.
dflt_faddr
;
else
{
bputs
(
text
[
InvalidNetMailAddr
]);
return
(
false
);
}
}
else
{
addr
=
atofaddr
(
&
cfg
,
p
+
1
);
/* Get fido address */
*
p
=
0
;
/* Chop off address */
if
(
mode
&
WM_FILE
&&
!
SYSOP
&&
!
(
cfg
.
inetmail_misc
&
NMAIL_FILE
))
mode
&=~
WM_FILE
;
return
inetmail
(
into
,
title
,
mode
|
WM_NETMAIL
);
}
p
=
strrchr
(
to
,
'@'
);
/* Find '@' in name@addr */
if
(
p
==
NULL
||
net_type
!=
NET_FIDO
)
{
bputs
(
text
[
InvalidNetMailAddr
]);
return
false
;
}
if
(
!
cfg
.
total_faddrs
||
(
!
SYSOP
&&
!
(
cfg
.
netmail_misc
&
NMAIL_ALLOW
)))
{
bputs
(
text
[
NoNetMailAllowed
]);
return
false
;
}
*
p
=
0
;
/* Chop off address */
p
++
;
SKIP_WHITESPACE
(
p
);
addr
=
atofaddr
(
&
cfg
,
p
);
/* Get fido address */
if
(
mode
&
WM_FILE
&&
!
SYSOP
&&
!
(
cfg
.
netmail_misc
&
NMAIL_FILE
))
mode
&=~
WM_FILE
;
if
((
!
SYSOP
&&
!
(
cfg
.
netmail_misc
&
NMAIL_ALLOW
))
||
useron
.
rest
&
FLAG
(
'M'
)
||
!
cfg
.
total_faddrs
)
{
bputs
(
text
[
NoNetMailAllowed
]);
return
(
false
);
}
truncsp
(
to
);
/* Truncate off space */
memset
(
&
hdr
,
0
,
sizeof
(
hdr
));
/* Initialize header to null */
...
...
@@ -449,7 +454,7 @@ void sbbs_t::qwktonetmail(FILE *rep, char *block, char *into, uchar fromhub)
char
*
sender_id
=
fromhub
?
cfg
.
qhub
[
fromhub
-
1
]
->
id
:
useron
.
alias
;
char
tmp
[
512
];
int
i
,
fido
,
inet
=
0
,
qnet
=
0
;
u
short
net
;
u
int16_t
net
;
uint16_t
xlat
;
long
l
,
offset
,
length
,
m
,
n
;
faddr_t
fidoaddr
;
...
...
@@ -764,7 +769,7 @@ void sbbs_t::qwktonetmail(FILE *rep, char *block, char *into, uchar fromhub)
smb_dfield
(
&
msg
,
TEXT_BODY
,
length
);
i
=
smb_addmsghdr
(
&
smb
,
&
msg
,
SMB_SELFPACK
);
i
=
smb_addmsghdr
(
&
smb
,
&
msg
,
smb_storage_mode
(
&
cfg
,
&
smb
)
);
smb_close
(
&
smb
);
smb_stack
(
&
smb
,
SMB_STACK_POP
);
...
...
src/sbbs3/file.cpp
View file @
53985a6b
...
...
@@ -212,6 +212,7 @@ void sbbs_t::closefile(file_t* f)
}
close
(
file
);
if
((
file
=
nopen
(
str1
,
O_WRONLY
|
O_TRUNC
))
==-
1
)
{
free
(
buf
);
errormsg
(
WHERE
,
ERR_OPEN
,
str1
,
O_WRONLY
|
O_TRUNC
);
return
;
}
...
...
src/sbbs3/filedat.c
View file @
53985a6b
...
...
@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright
2011
Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright Rob Swindell - http://www.synchro.net/copyright.html
*
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
...
...
@@ -252,7 +252,7 @@ BOOL DLLCALL addfiledat(scfg_t* cfg, file_t* f)
}
if
(
lread
(
file
,
ixbbuf
,
length
)
!=
length
)
{
close
(
file
);
free
(
(
char
*
)
ixbbuf
);
free
(
ixbbuf
);
return
(
FALSE
);
}
/************************************************/
...
...
@@ -263,7 +263,7 @@ BOOL DLLCALL addfiledat(scfg_t* cfg, file_t* f)
for
(
i
=
0
;
i
<
12
&&
toupper
(
fname
[
i
])
==
toupper
(
ixbbuf
[
l
+
i
]);
i
++
);
if
(
i
==
12
)
{
/* file already in directory index */
close
(
file
);
free
(
(
char
*
)
ixbbuf
);
free
(
ixbbuf
);
return
(
FALSE
);
}
if
(
cfg
->
dir
[
f
->
dir
]
->
sort
==
SORT_NAME_A
...
...
@@ -287,22 +287,22 @@ BOOL DLLCALL addfiledat(scfg_t* cfg, file_t* f)
lseek
(
file
,
l
,
SEEK_SET
);
if
(
write
(
file
,
fname
,
11
)
!=
11
)
{
/* Write filename to IXB file */
close
(
file
);
free
(
(
char
*
)
ixbbuf
);
free
(
ixbbuf
);
return
(
FALSE
);
}
if
(
write
(
file
,
idx
,
3
)
!=
3
)
{
/* Write DAT offset into IXB file */
close
(
file
);
free
(
(
char
*
)
ixbbuf
);
free
(
ixbbuf
);
return
(
FALSE
);
}
write
(
file
,
&
f
->
dateuled
,
4
);
write
(
file
,
&
f
->
datedled
,
4
);
/* Write 0 for datedled */
if
(
lwrite
(
file
,
&
ixbbuf
[
l
],
length
-
l
)
!=
length
-
l
)
{
/* Write rest of IXB */
close
(
file
);
free
(
(
char
*
)
ixbbuf
);
free
(
ixbbuf
);
return
(
FALSE
);
}
free
(
(
char
*
)
ixbbuf
);
free
(
ixbbuf
);
}
else
{
/* IXB file is empty... No files */
if
(
write
(
file
,
fname
,
11
)
!=
11
)
{
/* Write filename it IXB file */
...
...
@@ -348,7 +348,7 @@ BOOL DLLCALL getfileixb(scfg_t* cfg, file_t* f)
}
if
(
lread
(
file
,
ixbbuf
,
length
)
!=
length
)
{
close
(
file
);
free
(
(
char
*
)
ixbbuf
);
free
(
ixbbuf
);
return
(
FALSE
);
}
close
(
file
);
...
...
@@ -361,7 +361,7 @@ BOOL DLLCALL getfileixb(scfg_t* cfg, file_t* f)
break
;
}
if
(
l
>=
length
)
{
free
(
(
char
*
)
ixbbuf
);
free
(
ixbbuf
);
return
(
FALSE
);
}
l
+=
11
;
...
...
@@ -370,7 +370,7 @@ BOOL DLLCALL getfileixb(scfg_t* cfg, file_t* f)
|
((
long
)
ixbbuf
[
l
+
5
]
<<
16
)
|
((
long
)
ixbbuf
[
l
+
6
]
<<
24
);
f
->
datedled
=
ixbbuf
[
l
+
7
]
|
((
long
)
ixbbuf
[
l
+
8
]
<<
8
)
|
((
long
)
ixbbuf
[
l
+
9
]
<<
16
)
|
((
long
)
ixbbuf
[
l
+
10
]
<<
24
);
free
(
(
char
*
)
ixbbuf
);
free
(
ixbbuf
);
return
(
TRUE
);
}
...
...
@@ -455,11 +455,12 @@ BOOL DLLCALL removefiledat(scfg_t* cfg, file_t* f)
}
if
(
lread
(
file
,
ixbbuf
,
length
)
!=
length
)
{
close
(
file
);
free
(
(
char
*
)
ixbbuf
);
free
(
ixbbuf
);
return
(
FALSE
);
}
close
(
file
);
if
((
file
=
sopen
(
str
,
O_WRONLY
|
O_TRUNC
|
O_BINARY
,
SH_DENYRW
))
==-
1
)
{
free
(
ixbbuf
);
return
(
FALSE
);
}
for
(
l
=
0
;
l
<
length
;
l
+=
F_IXBSIZE
)
{
...
...
@@ -469,11 +470,11 @@ BOOL DLLCALL removefiledat(scfg_t* cfg, file_t* f)
if
(
stricmp
(
ixbname
,
fname
))
if
(
lwrite
(
file
,
&
ixbbuf
[
l
],
F_IXBSIZE
)
!=
F_IXBSIZE
)
{
close
(
file
);
free
(
(
char
*
)
ixbbuf
);
free
(
ixbbuf
);
return
(
FALSE
);
}
}
free
(
(
char
*
)
ixbbuf
);
free
(
ixbbuf
);
close
(
file
);
SAFEPRINTF2
(
str
,
"%s%s.dat"
,
cfg
->
dir
[
f
->
dir
]
->
data_dir
,
cfg
->
dir
[
f
->
dir
]
->
code
);
if
((
file
=
sopen
(
str
,
O_WRONLY
|
O_BINARY
,
SH_DENYRW
))
==-
1
)
{
...
...
@@ -519,7 +520,7 @@ BOOL DLLCALL findfile(scfg_t* cfg, uint dirnum, char *filename)
}
if
(
lread
(
file
,
ixbbuf
,
length
)
!=
length
)
{
close
(
file
);
free
(
(
char
*
)
ixbbuf
);
free
(
ixbbuf
);
return
(
FALSE
);
}
close
(
file
);
...
...
@@ -528,7 +529,7 @@ BOOL DLLCALL findfile(scfg_t* cfg, uint dirnum, char *filename)
if
(
toupper
(
fname
[
i
])
!=
toupper
(
ixbbuf
[
l
+
i
]))
break
;
if
(
i
==
11
)
break
;
}
free
(
(
char
*
)
ixbbuf
);
free
(
ixbbuf
);
if
(
l
!=
length
)
return
(
TRUE
);
return
(
FALSE
);
...
...
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