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
6ed2240b
Commit
6ed2240b
authored
1 year ago
by
Rob Swindell
Browse files
Options
Downloads
Patches
Plain Diff
Detect and reject invalid birthdates during new user registration
e.g. month and day reversed
parent
18596595
No related branches found
No related tags found
No related merge requests found
Pipeline
#5792
passed
1 year ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/sbbs3/newuser.cpp
+1
-1
1 addition, 1 deletion
src/sbbs3/newuser.cpp
src/sbbs3/userdat.c
+5
-1
5 additions, 1 deletion
src/sbbs3/userdat.c
with
6 additions
and
2 deletions
src/sbbs3/newuser.cpp
+
1
−
1
View file @
6ed2240b
...
...
@@ -286,7 +286,7 @@ bool sbbs_t::newuser()
if
(
gettmplt
(
str
,
birthdate_template
(
&
cfg
,
tmp
,
sizeof
tmp
),
K_EDIT
)
<
10
)
continue
;
int
age
=
getage
(
&
cfg
,
parse_birthdate
(
&
cfg
,
str
,
tmp
,
sizeof
(
tmp
)));
if
(
age
>=
0
&&
age
<=
200
)
{
// TODO: Configurable min/max user age
if
(
age
>=
1
&&
age
<=
200
)
{
// TODO: Configurable min/max user age
SAFECOPY
(
useron
.
birth
,
tmp
);
break
;
}
...
...
This diff is collapsed.
Click to expand it.
src/sbbs3/userdat.c
+
5
−
1
View file @
6ed2240b
...
...
@@ -983,6 +983,7 @@ char* getbirthdstr(scfg_t* cfg, const char* birth, char* buf, size_t max)
/****************************************************************************/
/* Returns the age derived from the string 'birth' in the format CCYYMMDD */
/* or legacy: MM/DD/YY or DD/MM/YY */
/* Returns 0 on invalid 'birth' date */
/****************************************************************************/
int
getage
(
scfg_t
*
cfg
,
const
char
*
birth
)
{
...
...
@@ -1003,7 +1004,10 @@ int getage(scfg_t* cfg, const char *birth)
int
year
=
getbirthyear
(
birth
);
int
age
=
(
1900
+
tm
.
tm_year
)
-
year
;
int
mon
=
getbirthmonth
(
cfg
,
birth
);
if
(
mon
>
tm
.
tm_mon
||
(
mon
==
tm
.
tm_mon
&&
getbirthday
(
cfg
,
birth
)
>
tm
.
tm_mday
))
int
day
=
getbirthday
(
cfg
,
birth
);
if
(
mon
<
1
||
mon
>
12
||
day
<
1
||
day
>
31
)
return
0
;
if
(
mon
>
tm
.
tm_mon
||
(
mon
==
tm
.
tm_mon
&&
day
>
tm
.
tm_mday
))
age
--
;
return
age
;
}
...
...
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