Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libplist
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
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
pwn
libplist
Commits
1c6aa3dd
Commit
1c6aa3dd
authored
Aug 07, 2008
by
Matt Colyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed the data corruption, it turns out that there is a maximum length
that you can request in an AFC packet 2^16.
parent
bef65596
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
30 deletions
+55
-30
AFC.c
src/AFC.c
+52
-30
ifuse.c
src/ifuse.c
+3
-0
No files found.
src/AFC.c
View file @
1c6aa3dd
...
...
@@ -386,41 +386,63 @@ AFCFile *afc_open_file(AFClient *client, const char *filename, uint32 file_mode)
return
NULL
;
}
/** Attempts to the read the given number of bytes from the given file.
*
* @param client The relevant AFC client
* @param file The AFCFile to read from
* @param data The pointer to the memory region to store the read data
* @param length The number of bytes to read
*
* @return The number of bytes read if successful. If there was an error
*/
int
afc_read_file
(
AFClient
*
client
,
AFCFile
*
file
,
char
*
data
,
int
length
)
{
if
(
!
client
||
!
client
->
afc_packet
||
!
client
->
connection
||
!
file
)
return
-
1
;
AFCFilePacket
*
packet
=
(
AFCFilePacket
*
)
malloc
(
sizeof
(
AFCFilePacket
));
if
(
debug
)
printf
(
"afc_read_file called for length %i
\n
"
);
afc_lock
(
client
);
if
(
debug
)
printf
(
"afc_read_file called for length %i
\n
"
,
length
);
char
*
input
=
NULL
;
int
current_count
=
0
,
bytes
=
0
;
const
int
MAXIMUM_READ_SIZE
=
1
<<
16
;
afc_lock
(
client
);
// Looping here to get around the maximum amount of data that recieve_AFC_data can handle
while
(
current_count
<
length
){
// Send the read command
AFCFilePacket
*
packet
=
(
AFCFilePacket
*
)
malloc
(
sizeof
(
AFCFilePacket
));
packet
->
unknown1
=
packet
->
unknown2
=
0
;
packet
->
filehandle
=
file
->
filehandle
;
packet
->
size
=
length
;
int
bytes
=
0
;
packet
->
size
=
((
length
-
current_count
)
<
MAXIMUM_READ_SIZE
)
?
(
length
-
current_count
)
:
MAXIMUM_READ_SIZE
;
client
->
afc_packet
->
operation
=
AFC_READ
;
client
->
afc_packet
->
entire_length
=
client
->
afc_packet
->
this_length
=
0
;
bytes
=
dispatch_AFC_packet
(
client
,
(
char
*
)
packet
,
sizeof
(
AFCFilePacket
));
// If we get a positive reponse to the command gather the data
if
(
bytes
>
0
)
{
bytes
=
receive_AFC_data
(
client
,
&
input
);
afc_unlock
(
client
);
if
(
bytes
<
0
)
{
if
(
input
)
free
(
input
);
return
-
1
;
}
else
if
(
bytes
==
0
)
{
if
(
input
)
free
(
input
);
return
0
;
return
current_count
;
}
else
{
if
(
input
)
memcpy
(
data
,
input
,
(
bytes
>
length
)
?
length
:
bytes
);
if
(
input
)
{
printf
(
"afc_read_file: %d
\n
"
,
bytes
);
memcpy
(
data
+
current_count
,
input
,
(
bytes
>
length
)
?
length
:
bytes
);
free
(
input
);
return
(
bytes
>
length
)
?
length
:
bytes
;
input
=
NULL
;
current_count
+=
(
bytes
>
length
)
?
length
:
bytes
;
}
}
}
else
{
afc_unlock
(
client
);
return
-
1
;
}
return
0
;
}
afc_unlock
(
client
);
return
current_count
;
}
int
afc_write_file
(
AFClient
*
client
,
AFCFile
*
file
,
const
char
*
data
,
int
length
)
{
...
...
src/ifuse.c
View file @
1c6aa3dd
...
...
@@ -103,6 +103,9 @@ static int ifuse_read(const char *path, char *buf, size_t size, off_t offset,
AFCFile
*
file
;
AFClient
*
afc
=
fuse_get_context
()
->
private_data
;
if
(
size
==
0
)
return
0
;
file
=
g_hash_table_lookup
(
file_handles
,
&
(
fi
->
fh
));
if
(
!
file
){
return
-
ENOENT
;
...
...
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