Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
tg
Commits
5de0d759
Commit
5de0d759
authored
Jan 13, 2014
by
antma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add functions tstrndup (auto check return value of strndup calls)
parent
2724878b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
7 deletions
+25
-7
binlog.c
binlog.c
+1
-1
interface.c
interface.c
+5
-5
queries.c
queries.c
+1
-1
tools.c
tools.c
+17
-0
tools.h
tools.h
+1
-0
No files found.
binlog.c
View file @
5de0d759
...
@@ -100,7 +100,7 @@ void replay_log_event (void) {
...
@@ -100,7 +100,7 @@ void replay_log_event (void) {
if
(
verbosity
)
{
if
(
verbosity
)
{
logprintf
(
"id = %d, name = %.*s ip = %.*s port = %d
\n
"
,
id
,
l1
,
name
,
l2
,
ip
,
port
);
logprintf
(
"id = %d, name = %.*s ip = %.*s port = %d
\n
"
,
id
,
l1
,
name
,
l2
,
ip
,
port
);
}
}
alloc_dc
(
id
,
strndup
(
ip
,
l2
),
port
);
alloc_dc
(
id
,
t
strndup
(
ip
,
l2
),
port
);
}
}
rptr
=
in_ptr
;
rptr
=
in_ptr
;
break
;
break
;
...
...
interface.c
View file @
5de0d759
...
@@ -675,7 +675,7 @@ void interpreter (char *line UU) {
...
@@ -675,7 +675,7 @@ void interpreter (char *line UU) {
printf
(
"Empty file name
\n
"
);
printf
(
"Empty file name
\n
"
);
RET
;
RET
;
}
}
do_send_photo
(
CODE_input_media_uploaded_photo
,
id
,
strndup
(
s
,
t
));
do_send_photo
(
CODE_input_media_uploaded_photo
,
id
,
t
strndup
(
s
,
t
));
}
else
if
(
IS_WORD
(
"send_video"
))
{
}
else
if
(
IS_WORD
(
"send_video"
))
{
GET_PEER
;
GET_PEER
;
int
t
;
int
t
;
...
@@ -684,7 +684,7 @@ void interpreter (char *line UU) {
...
@@ -684,7 +684,7 @@ void interpreter (char *line UU) {
printf
(
"Empty file name
\n
"
);
printf
(
"Empty file name
\n
"
);
RET
;
RET
;
}
}
do_send_photo
(
CODE_input_media_uploaded_video
,
id
,
strndup
(
s
,
t
));
do_send_photo
(
CODE_input_media_uploaded_video
,
id
,
t
strndup
(
s
,
t
));
}
else
if
(
IS_WORD
(
"send_text"
))
{
}
else
if
(
IS_WORD
(
"send_text"
))
{
GET_PEER
;
GET_PEER
;
int
t
;
int
t
;
...
@@ -693,7 +693,7 @@ void interpreter (char *line UU) {
...
@@ -693,7 +693,7 @@ void interpreter (char *line UU) {
printf
(
"Empty file name
\n
"
);
printf
(
"Empty file name
\n
"
);
RET
;
RET
;
}
}
do_send_text
(
id
,
strndup
(
s
,
t
));
do_send_text
(
id
,
t
strndup
(
s
,
t
));
}
else
if
(
IS_WORD
(
"fwd"
))
{
}
else
if
(
IS_WORD
(
"fwd"
))
{
GET_PEER
;
GET_PEER
;
int
num
=
next_token_int
();
int
num
=
next_token_int
();
...
@@ -950,7 +950,7 @@ void interpreter (char *line UU) {
...
@@ -950,7 +950,7 @@ void interpreter (char *line UU) {
printf
(
"Empty file name
\n
"
);
printf
(
"Empty file name
\n
"
);
RET
;
RET
;
}
}
do_send_photo
(
CODE_input_media_uploaded_audio
,
id
,
strndup
(
s
,
t
));
do_send_photo
(
CODE_input_media_uploaded_audio
,
id
,
t
strndup
(
s
,
t
));
}
else
if
(
IS_WORD
(
"send_document"
))
{
}
else
if
(
IS_WORD
(
"send_document"
))
{
GET_PEER
;
GET_PEER
;
int
t
;
int
t
;
...
@@ -959,7 +959,7 @@ void interpreter (char *line UU) {
...
@@ -959,7 +959,7 @@ void interpreter (char *line UU) {
printf
(
"Empty file name
\n
"
);
printf
(
"Empty file name
\n
"
);
RET
;
RET
;
}
}
do_send_photo
(
CODE_input_media_uploaded_document
,
id
,
strndup
(
s
,
t
));
do_send_photo
(
CODE_input_media_uploaded_document
,
id
,
t
strndup
(
s
,
t
));
}
else
if
(
IS_WORD
(
"load_audio"
))
{
}
else
if
(
IS_WORD
(
"load_audio"
))
{
long
long
num
=
next_token_int
();
long
long
num
=
next_token_int
();
if
(
num
==
NOT_FOUND
)
{
if
(
num
==
NOT_FOUND
)
{
...
...
queries.c
View file @
5de0d759
...
@@ -386,7 +386,7 @@ int send_code_on_answer (struct query *q UU) {
...
@@ -386,7 +386,7 @@ int send_code_on_answer (struct query *q UU) {
if
(
phone_code_hash
)
{
if
(
phone_code_hash
)
{
tfree_str
(
phone_code_hash
);
tfree_str
(
phone_code_hash
);
}
}
phone_code_hash
=
strndup
(
s
,
l
);
phone_code_hash
=
t
strndup
(
s
,
l
);
want_dc_num
=
-
1
;
want_dc_num
=
-
1
;
return
0
;
return
0
;
}
}
...
...
tools.c
View file @
5de0d759
...
@@ -166,6 +166,23 @@ char *tstrdup (const char *s) {
...
@@ -166,6 +166,23 @@ char *tstrdup (const char *s) {
#endif
#endif
}
}
char
*
tstrndup
(
const
char
*
s
,
size_t
n
)
{
#ifdef DEBUG
size_t
l
=
0
;
for
(
l
=
0
;
l
<
n
&&
s
[
l
];
l
++
)
{
}
char
*
p
=
talloc
(
l
+
1
);
memcpy
(
p
,
s
,
l
);
p
[
l
]
=
0
;
return
p
;
#else
char
*
p
=
strndup
(
s
,
n
);
if
(
p
==
NULL
)
{
out_of_memory
();
}
return
p
;
#endif
}
void
ensure
(
int
r
)
{
void
ensure
(
int
r
)
{
if
(
!
r
)
{
if
(
!
r
)
{
logprintf
(
"Open SSL error
\n
"
);
logprintf
(
"Open SSL error
\n
"
);
...
...
tools.h
View file @
5de0d759
...
@@ -24,6 +24,7 @@ void *talloc (size_t size);
...
@@ -24,6 +24,7 @@ void *talloc (size_t size);
void
*
trealloc
(
void
*
ptr
,
size_t
old_size
,
size_t
size
);
void
*
trealloc
(
void
*
ptr
,
size_t
old_size
,
size_t
size
);
void
*
talloc0
(
size_t
size
);
void
*
talloc0
(
size_t
size
);
char
*
tstrdup
(
const
char
*
s
);
char
*
tstrdup
(
const
char
*
s
);
char
*
tstrndup
(
const
char
*
s
,
size_t
n
);
int
tinflate
(
void
*
input
,
int
ilen
,
void
*
output
,
int
olen
);
int
tinflate
(
void
*
input
,
int
ilen
,
void
*
output
,
int
olen
);
void
ensure
(
int
r
);
void
ensure
(
int
r
);
void
ensure_ptr
(
void
*
p
);
void
ensure_ptr
(
void
*
p
);
...
...
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