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
4f11e1df
Commit
4f11e1df
authored
Mar 01, 2022
by
Rob Swindell
💬
Browse files
Better detection of correctly-null-terminated body text
CID 229603
parent
77b90b5f
Pipeline
#2825
passed with stage
in 9 minutes and 38 seconds
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
src/sbbs3/fmsgdump.c
src/sbbs3/fmsgdump.c
+9
-5
No files found.
src/sbbs3/fmsgdump.c
View file @
4f11e1df
...
...
@@ -85,7 +85,7 @@ int msgdump(FILE* fp, const char* fname)
if
(
hdr
.
subj
[
sizeof
(
hdr
.
subj
)
-
1
]
!=
0
)
fprintf
(
stderr
,
"%s Unterminated 'subj' field
\n
"
,
fname
);
if
(
hdr
.
time
[
sizeof
(
hdr
.
time
)
-
1
]
!=
0
)
fprintf
(
stderr
,
"%s Untermi
a
nted 'time' field
\n
"
,
fname
);
fprintf
(
stderr
,
"%s Untermin
a
ted 'time' field
\n
"
,
fname
);
printf
(
"Subj: %.*s
\n
"
,
(
int
)
sizeof
(
hdr
.
subj
)
-
1
,
hdr
.
subj
);
...
...
@@ -103,16 +103,17 @@ int msgdump(FILE* fp, const char* fname)
return
(
__COUNTER__
);
}
char
*
body
=
calloc
((
end
-
sizeof
(
hdr
))
+
1
,
1
);
long
len
=
end
-
sizeof
(
hdr
);
char
*
body
=
calloc
(
len
+
1
,
1
);
if
(
body
==
NULL
)
{
fprintf
(
stderr
,
"!MALLOC failure
\n
"
);
return
__COUNTER__
;
}
fseek
(
fp
,
sizeof
(
hdr
),
SEEK_SET
);
fread
(
body
,
en
d
-
sizeof
(
hdr
)
,
1
,
fp
);
fread
(
body
,
l
en
,
1
,
fp
);
fprintf
(
bodyfp
,
"
\n
-start of message text-
\n
"
);
char
*
p
=
body
;
while
(
*
p
)
{
while
(
*
p
&&
p
<
body
+
len
)
{
if
((
p
==
body
||
*
(
p
-
1
)
==
'\r'
)
&&
*
p
==
1
)
{
fputc
(
'@'
,
ctrlfp
);
p
++
;
...
...
@@ -132,7 +133,10 @@ int msgdump(FILE* fp, const char* fname)
fputc
(
'\n'
,
bodyfp
);
}
}
fprintf
(
bodyfp
,
"-end of message text-
\n
"
);
if
(
p
==
(
body
+
len
)
-
1
)
fprintf
(
bodyfp
,
"-end of message text-
\n
"
);
else
fprintf
(
bodyfp
,
"-PREMATURE end of message text-
\n
"
);
free
(
body
);
printf
(
"
\n
"
);
...
...
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