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
2724878b
Commit
2724878b
authored
Jan 13, 2014
by
antma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix small memory leaks in the function do_send_photo for the cases of invalid, empty or large file
parent
06a26ebc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
queries.c
queries.c
+10
-5
No files found.
queries.c
View file @
2724878b
...
@@ -1462,6 +1462,7 @@ void do_send_photo (int type, peer_id_t to_id, char *file_name) {
...
@@ -1462,6 +1462,7 @@ void do_send_photo (int type, peer_id_t to_id, char *file_name) {
int
fd
=
open
(
file_name
,
O_RDONLY
);
int
fd
=
open
(
file_name
,
O_RDONLY
);
if
(
fd
<
0
)
{
if
(
fd
<
0
)
{
rprintf
(
"No such file '%s'
\n
"
,
file_name
);
rprintf
(
"No such file '%s'
\n
"
,
file_name
);
tfree_str
(
file_name
);
return
;
return
;
}
}
struct
stat
buf
;
struct
stat
buf
;
...
@@ -1469,6 +1470,7 @@ void do_send_photo (int type, peer_id_t to_id, char *file_name) {
...
@@ -1469,6 +1470,7 @@ void do_send_photo (int type, peer_id_t to_id, char *file_name) {
long
long
size
=
buf
.
st_size
;
long
long
size
=
buf
.
st_size
;
if
(
size
<=
0
)
{
if
(
size
<=
0
)
{
rprintf
(
"File has zero length
\n
"
);
rprintf
(
"File has zero length
\n
"
);
tfree_str
(
file_name
);
close
(
fd
);
close
(
fd
);
return
;
return
;
}
}
...
@@ -1483,6 +1485,14 @@ void do_send_photo (int type, peer_id_t to_id, char *file_name) {
...
@@ -1483,6 +1485,14 @@ void do_send_photo (int type, peer_id_t to_id, char *file_name) {
f
->
part_size
*=
2
;
f
->
part_size
*=
2
;
}
}
if
(
f
->
part_size
>
(
512
<<
10
))
{
close
(
fd
);
rprintf
(
"Too big file. Maximal supported size is %d.
\n
"
,
(
512
<<
10
)
*
1000
);
tfree
(
f
,
sizeof
(
*
f
));
tfree_str
(
file_name
);
return
;
}
f
->
id
=
lrand48
()
*
(
1ll
<<
32
)
+
lrand48
();
f
->
id
=
lrand48
()
*
(
1ll
<<
32
)
+
lrand48
();
f
->
to_id
=
to_id
;
f
->
to_id
=
to_id
;
f
->
media_type
=
type
;
f
->
media_type
=
type
;
...
@@ -1496,11 +1506,6 @@ void do_send_photo (int type, peer_id_t to_id, char *file_name) {
...
@@ -1496,11 +1506,6 @@ void do_send_photo (int type, peer_id_t to_id, char *file_name) {
f
->
key
=
talloc
(
32
);
f
->
key
=
talloc
(
32
);
secure_random
(
f
->
key
,
32
);
secure_random
(
f
->
key
,
32
);
}
}
if
(
f
->
part_size
>
(
512
<<
10
))
{
close
(
fd
);
rprintf
(
"Too big file. Maximal supported size is %d"
,
(
512
<<
10
)
*
1000
);
return
;
}
if
(
f
->
media_type
==
CODE_input_media_uploaded_video
&&
!
f
->
encr
)
{
if
(
f
->
media_type
==
CODE_input_media_uploaded_video
&&
!
f
->
encr
)
{
f
->
media_type
=
CODE_input_media_uploaded_thumb_video
;
f
->
media_type
=
CODE_input_media_uploaded_thumb_video
;
send_file_thumb
(
f
);
send_file_thumb
(
f
);
...
...
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