Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
f46e4fac
Commit
f46e4fac
authored
May 10, 2010
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
introduced my_strlcpy
parent
d94c3f8b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
chat.c
examples/chat.c
+8
-3
No files found.
examples/chat.c
View file @
f46e4fac
...
...
@@ -158,6 +158,11 @@ static struct message *new_message(void) {
return
message
;
}
static
void
my_strlcpy
(
char
*
dst
,
const
char
*
src
,
size_t
len
)
{
strncpy
(
dst
,
src
,
len
);
dst
[
len
-
1
]
=
'\0'
;
}
// A handler for the /ajax/send_message endpoint.
static
void
ajax_send_message
(
struct
mg_connection
*
conn
,
const
struct
mg_request_info
*
request_info
)
{
...
...
@@ -178,8 +183,8 @@ static void ajax_send_message(struct mg_connection *conn,
// TODO(lsm): JSON-encode all text strings
session
=
get_session
(
conn
);
assert
(
session
!=
NULL
);
strlcpy
(
message
->
text
,
text
,
sizeof
(
text
));
strlcpy
(
message
->
user
,
session
->
user
,
sizeof
(
message
->
user
));
my_
strlcpy
(
message
->
text
,
text
,
sizeof
(
text
));
my_
strlcpy
(
message
->
user
,
session
->
user
,
sizeof
(
message
->
user
));
pthread_rwlock_unlock
(
&
rwlock
);
}
...
...
@@ -276,7 +281,7 @@ static void authorize(struct mg_connection *conn,
// authentication. The danger of doing this is that session cookie can
// be stolen and an attacker may impersonate the user.
// Secure application must use HTTPS all the time.
strlcpy
(
session
->
user
,
user
,
sizeof
(
session
->
user
));
my_
strlcpy
(
session
->
user
,
user
,
sizeof
(
session
->
user
));
snprintf
(
session
->
random
,
sizeof
(
session
->
random
),
"%d"
,
rand
());
generate_session_id
(
session
->
session_id
,
session
->
random
,
session
->
user
,
request_info
);
...
...
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