Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
ac811ab2
Commit
ac811ab2
authored
2 years ago
by
Rob Swindell
Browse files
Options
Downloads
Patches
Plain Diff
Safer string handling
e.g. CID 33631: Unbounded source buffer
parent
3ab210cb
No related branches found
No related tags found
1 merge request
!463
MRC mods by Codefenix (2024-10-20)
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sbbs3/filelist.c
+12
-23
12 additions, 23 deletions
src/sbbs3/filelist.c
with
12 additions
and
23 deletions
src/sbbs3/filelist.c
+
12
−
23
View file @
ac811ab2
/* Utility to create list of files from Synchronet file directories */
/* DEPRECATED: use filelist.js instead */
/* Default list format is FILES.BBS, but file size, uploader, upload date */
/* and other information can be included. */
...
...
@@ -55,31 +57,18 @@ int lprintf(int level, const char *fmat, ...)
return
(
chcount
);
}
void
stripctrlz
(
char
*
str
)
{
char
tmp
[
1024
];
int
i
,
j
,
k
;
k
=
strlen
(
str
);
for
(
i
=
j
=
0
;
i
<
k
;
i
++
)
if
(
str
[
i
]
!=
0x1a
)
tmp
[
j
++
]
=
str
[
i
];
tmp
[
j
]
=
0
;
strcpy
(
str
,
tmp
);
}
char
*
byteStr
(
unsigned
long
value
)
{
static
char
tmp
[
128
];
if
(
value
>=
(
1024
*
1024
*
1024
))
sprintf
(
tmp
,
"%5.1fG"
,
value
/
(
1024
.
0
*
1024
.
0
*
1024
.
0
));
SAFEPRINTF
(
tmp
,
"%5.1fG"
,
value
/
(
1024
.
0
*
1024
.
0
*
1024
.
0
));
else
if
(
value
>=
(
1024
*
1024
))
sprintf
(
tmp
,
"%5.1fM"
,
value
/
(
1024
.
0
*
1024
.
0
));
SAFEPRINTF
(
tmp
,
"%5.1fM"
,
value
/
(
1024
.
0
*
1024
.
0
));
else
if
(
value
>=
1024
)
sprintf
(
tmp
,
"%5.1fK"
,
value
/
1024
.
0
);
SAFEPRINTF
(
tmp
,
"%5.1fK"
,
value
/
1024
.
0
);
else
sprintf
(
tmp
,
"%5luB"
,
value
);
SAFEPRINTF
(
tmp
,
"%5luB"
,
value
);
return
tmp
;
}
...
...
@@ -234,7 +223,8 @@ int main(int argc, char **argv)
printf
(
"
\n
Directory internal code must follow -not parameter.
\n
"
);
exit
(
1
);
}
sprintf
(
not
[
nots
++
],
"%.8s"
,
argv
[
i
]);
SAFECOPY
(
not
[
nots
],
argv
[
i
]);
nots
++
;
}
else
if
(
!
stricmp
(
argv
[
i
],
"-all"
))
{
if
(
dirnum
!=-
1
)
{
...
...
@@ -343,14 +333,14 @@ int main(int argc, char **argv)
,
/* filespec: */
pattern
,
/* time: */
t
,
file_detail_extdesc
,
scfg
.
dir
[
i
]
->
sort
,
&
file_count
);
if
(
misc
&
AUTO
)
{
sprintf
(
str
,
"%sFILES.BBS"
,
scfg
.
dir
[
i
]
->
path
);
SAFEPRINTF
(
str
,
"%sFILES.BBS"
,
scfg
.
dir
[
i
]
->
path
);
if
((
out
=
fopen
(
str
,
omode
))
==
NULL
)
{
perror
(
str
);
exit
(
1
);
}
}
if
(
misc
&
HDR
)
{
sprintf
(
fname
,
"%-*s %-*s Files: %4lu"
s
afe_sn
printf
(
fname
,
sizeof
(
fname
),
"%-*s %-*s Files: %4lu"
,
LEN_GSNAME
,
scfg
.
lib
[
scfg
.
dir
[
i
]
->
lib
]
->
sname
,
LEN_SLNAME
,
scfg
.
dir
[
i
]
->
lname
,
(
ulong
)
smb
.
status
.
total_files
);
fprintf
(
out
,
"%s
\n
"
,
fname
);
...
...
@@ -400,7 +390,7 @@ int main(int argc, char **argv)
}
if
(
misc
&
MINUS
)
{
sprintf
(
str
,
"%s%s"
,
scfg
.
dir
[
i
]
->
path
,
file
.
name
);
SAFEPRINTF2
(
str
,
"%s%s"
,
scfg
.
dir
[
i
]
->
path
,
file
.
name
);
if
(
!
fexistcase
(
str
))
fputc
(
'-'
,
out
);
else
...
...
@@ -411,8 +401,7 @@ int main(int argc, char **argv)
desc_off
++
;
if
(
misc
&
DFD
)
{
// TODO: Fix to support alt-file-paths:
sprintf
(
str
,
"%s%s"
,
scfg
.
dir
[
i
]
->
path
,
file
.
name
);
SAFEPRINTF2
(
str
,
"%s%s"
,
scfg
.
dir
[
i
]
->
path
,
file
.
name
);
desc_off
+=
fprintf
(
out
,
"%s "
,
unixtodstr
(
&
scfg
,(
time32_t
)
fdate
(
str
),
str
));
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment