Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Sleuthkit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IRT
Sleuthkit
Commits
f5c3ab17
Commit
f5c3ab17
authored
10 years ago
by
Brian Carrier
Browse files
Options
Downloads
Plain Diff
Merge pull request #482 from sleuthkit/yaffs_warnings
fix compiler warnings in YAFFS
parents
68db50aa
75663ac3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tsk/fs/yaffs.cpp
+19
-20
19 additions, 20 deletions
tsk/fs/yaffs.cpp
with
19 additions
and
20 deletions
tsk/fs/yaffs.cpp
+
19
−
20
View file @
f5c3ab17
...
@@ -945,7 +945,6 @@ yaffs_initialize_spare_format(YAFFSFS_INFO * yfs, TSK_OFF_T maxBlocksToTest){
...
@@ -945,7 +945,6 @@ yaffs_initialize_spare_format(YAFFSFS_INFO * yfs, TSK_OFF_T maxBlocksToTest){
unsigned
int
blockSize
=
yfs
->
chunks_per_block
*
chunkSize
;
unsigned
int
blockSize
=
yfs
->
chunks_per_block
*
chunkSize
;
TSK_FS_INFO
*
fs
=
&
(
yfs
->
fs_info
);
TSK_FS_INFO
*
fs
=
&
(
yfs
->
fs_info
);
unsigned
int
cnt
;
unsigned
char
*
spareBuffer
;
unsigned
char
*
spareBuffer
;
unsigned
int
blockIndex
;
unsigned
int
blockIndex
;
...
@@ -955,7 +954,7 @@ yaffs_initialize_spare_format(YAFFSFS_INFO * yfs, TSK_OFF_T maxBlocksToTest){
...
@@ -955,7 +954,7 @@ yaffs_initialize_spare_format(YAFFSFS_INFO * yfs, TSK_OFF_T maxBlocksToTest){
unsigned
char
*
allSpares
;
unsigned
char
*
allSpares
;
unsigned
int
allSparesLength
;
unsigned
int
allSparesLength
;
TSK_OFF_T
offset
;
TSK_OFF_T
maxBlocks
;
TSK_OFF_T
maxBlocks
;
bool
skipBlock
;
bool
skipBlock
;
...
@@ -1013,19 +1012,19 @@ yaffs_initialize_spare_format(YAFFSFS_INFO * yfs, TSK_OFF_T maxBlocksToTest){
...
@@ -1013,19 +1012,19 @@ yaffs_initialize_spare_format(YAFFSFS_INFO * yfs, TSK_OFF_T maxBlocksToTest){
// If maxBlocksToTest = 0 (unlimited), set it to the total number of blocks
// If maxBlocksToTest = 0 (unlimited), set it to the total number of blocks
// Also reduce the number of blocks to test if it is larger than the total number of blocks
// Also reduce the number of blocks to test if it is larger than the total number of blocks
if
((
maxBlocksToTest
==
0
)
||
(
maxBlocksToTest
>
maxBlocks
)){
if
((
maxBlocksToTest
==
0
)
||
(
maxBlocksToTest
>
maxBlocks
)){
maxBlocksToTest
=
maxBlocks
;
maxBlocksToTest
=
maxBlocks
;
}
}
nGoodSpares
=
0
;
nGoodSpares
=
0
;
nBlocksTested
=
0
;
nBlocksTested
=
0
;
for
(
TSK_OFF_T
blockIndex
=
0
;
blockIndex
<
maxBlocksToTest
;
blockIndex
++
){
for
(
TSK_OFF_T
blockIndex
=
0
;
blockIndex
<
maxBlocksToTest
;
blockIndex
++
){
// Read the last spare area that we want to test first
// Read the last spare area that we want to test first
offset
=
(
TSK_OFF_T
)
blockIndex
*
blockSize
+
(
chunksToTest
-
1
)
*
chunkSize
+
yfs
->
page_size
;
TSK_OFF_T
offset
=
(
TSK_OFF_T
)
blockIndex
*
blockSize
+
(
chunksToTest
-
1
)
*
chunkSize
+
yfs
->
page_size
;
cnt
=
tsk_img_read
(
fs
->
img_info
,
offset
,
(
char
*
)
spareBuffer
,
ssize_t
cnt
=
tsk_img_read
(
fs
->
img_info
,
offset
,
(
char
*
)
spareBuffer
,
yfs
->
spare_size
);
yfs
->
spare_size
);
if
(
cnt
==
-
1
||
cnt
<
yfs
->
spare_size
)
{
if
(
(
cnt
<
0
)
||
((
unsigned
int
)
cnt
<
yfs
->
spare_size
)
)
{
break
;
break
;
}
}
...
@@ -1034,14 +1033,14 @@ yaffs_initialize_spare_format(YAFFSFS_INFO * yfs, TSK_OFF_T maxBlocksToTest){
...
@@ -1034,14 +1033,14 @@ yaffs_initialize_spare_format(YAFFSFS_INFO * yfs, TSK_OFF_T maxBlocksToTest){
// - can't have an unallocated chunk followed by an allocated one
// - can't have an unallocated chunk followed by an allocated one
// We occasionally see almost all null spare area with a few 0xff, which is not a valid spare.
// We occasionally see almost all null spare area with a few 0xff, which is not a valid spare.
skipBlock
=
true
;
skipBlock
=
true
;
for
(
i
=
0
;
i
<
yfs
->
spare_size
;
i
++
){
for
(
i
=
0
;
i
<
yfs
->
spare_size
;
i
++
){
if
((
spareBuffer
[
i
]
!=
0xff
)
&&
(
spareBuffer
[
i
]
!=
0x00
)){
if
((
spareBuffer
[
i
]
!=
0xff
)
&&
(
spareBuffer
[
i
]
!=
0x00
)){
skipBlock
=
false
;
skipBlock
=
false
;
break
;
break
;
}
}
}
}
if
(
skipBlock
){
if
(
skipBlock
){
continue
;
continue
;
}
}
...
@@ -1050,16 +1049,16 @@ yaffs_initialize_spare_format(YAFFSFS_INFO * yfs, TSK_OFF_T maxBlocksToTest){
...
@@ -1050,16 +1049,16 @@ yaffs_initialize_spare_format(YAFFSFS_INFO * yfs, TSK_OFF_T maxBlocksToTest){
// Copy this spare area
// Copy this spare area
nGoodSpares
++
;
nGoodSpares
++
;
for
(
i
=
0
;
i
<
yfs
->
spare_size
;
i
++
){
for
(
i
=
0
;
i
<
yfs
->
spare_size
;
i
++
){
allSpares
[
nBlocksTested
*
yfs
->
spare_size
*
chunksToTest
+
(
chunksToTest
-
1
)
*
yfs
->
spare_size
+
i
]
=
spareBuffer
[
i
];
allSpares
[
nBlocksTested
*
yfs
->
spare_size
*
chunksToTest
+
(
chunksToTest
-
1
)
*
yfs
->
spare_size
+
i
]
=
spareBuffer
[
i
];
}
}
// Copy all earlier spare areas in the block
// Copy all earlier spare areas in the block
for
(
chunkIndex
=
0
;
chunkIndex
<
chunksToTest
-
1
;
chunkIndex
++
){
for
(
chunkIndex
=
0
;
chunkIndex
<
chunksToTest
-
1
;
chunkIndex
++
){
offset
=
blockIndex
*
blockSize
+
chunkIndex
*
chunkSize
+
yfs
->
page_size
;
offset
=
blockIndex
*
blockSize
+
chunkIndex
*
chunkSize
+
yfs
->
page_size
;
cnt
=
tsk_img_read
(
fs
->
img_info
,
offset
,
(
char
*
)
spareBuffer
,
cnt
=
tsk_img_read
(
fs
->
img_info
,
offset
,
(
char
*
)
spareBuffer
,
yfs
->
spare_size
);
yfs
->
spare_size
);
if
(
cnt
==
-
1
||
cnt
<
yfs
->
spare_size
)
{
if
(
(
cnt
<
0
)
||
((
unsigned
int
)
cnt
<
yfs
->
spare_size
)
)
{
// We really shouldn't run out of data here since we already read in the furthest entry
// We really shouldn't run out of data here since we already read in the furthest entry
break
;
// Break out of chunksToTest loop
break
;
// Break out of chunksToTest loop
}
}
...
@@ -1074,15 +1073,15 @@ yaffs_initialize_spare_format(YAFFSFS_INFO * yfs, TSK_OFF_T maxBlocksToTest){
...
@@ -1074,15 +1073,15 @@ yaffs_initialize_spare_format(YAFFSFS_INFO * yfs, TSK_OFF_T maxBlocksToTest){
nBlocksTested
++
;
nBlocksTested
++
;
// If we've found enough potentailly valid blocks, break
// If we've found enough potentailly valid blocks, break
if
(
nBlocksTested
>=
blocksToTest
){
if
(
nBlocksTested
>=
blocksToTest
){
break
;
break
;
}
}
}
}
// Make sure we read enough data to reasonably perform the testing
// Make sure we read enough data to reasonably perform the testing
if
(
nGoodSpares
<
minChunksRead
){
if
(
nGoodSpares
<
minChunksRead
){
if
(
tsk_verbose
&&
(
!
yfs
->
autoDetect
)){
if
(
tsk_verbose
&&
(
!
yfs
->
autoDetect
)){
tsk_fprintf
(
stderr
,
tsk_fprintf
(
stderr
,
"yaffs_initialize_spare_format failed - not enough potentially valid data could be read
\n
"
);
"yaffs_initialize_spare_format failed - not enough potentially valid data could be read
\n
"
);
}
}
...
@@ -1092,7 +1091,7 @@ yaffs_initialize_spare_format(YAFFSFS_INFO * yfs, TSK_OFF_T maxBlocksToTest){
...
@@ -1092,7 +1091,7 @@ yaffs_initialize_spare_format(YAFFSFS_INFO * yfs, TSK_OFF_T maxBlocksToTest){
return
TSK_ERR
;
return
TSK_ERR
;
}
}
if
(
tsk_verbose
&&
(
!
yfs
->
autoDetect
)){
if
(
tsk_verbose
&&
(
!
yfs
->
autoDetect
)){
tsk_fprintf
(
stderr
,
tsk_fprintf
(
stderr
,
"yaffs_initialize_spare_format: Testing potential offsets for the sequence number in the spare area
\n
"
);
"yaffs_initialize_spare_format: Testing potential offsets for the sequence number in the spare area
\n
"
);
}
}
...
@@ -1293,7 +1292,7 @@ static uint8_t
...
@@ -1293,7 +1292,7 @@ static uint8_t
yaffsfs_read_header
(
YAFFSFS_INFO
*
yfs
,
YaffsHeader
**
header
,
TSK_OFF_T
offset
)
yaffsfs_read_header
(
YAFFSFS_INFO
*
yfs
,
YaffsHeader
**
header
,
TSK_OFF_T
offset
)
{
{
unsigned
char
*
hdr
;
unsigned
char
*
hdr
;
unsigned
in
t
cnt
;
ssize_
t
cnt
;
YaffsHeader
*
head
;
YaffsHeader
*
head
;
TSK_FS_INFO
*
fs
=
&
(
yfs
->
fs_info
);
TSK_FS_INFO
*
fs
=
&
(
yfs
->
fs_info
);
...
@@ -1303,7 +1302,7 @@ static uint8_t
...
@@ -1303,7 +1302,7 @@ static uint8_t
cnt
=
tsk_img_read
(
fs
->
img_info
,
offset
,
(
char
*
)
hdr
,
cnt
=
tsk_img_read
(
fs
->
img_info
,
offset
,
(
char
*
)
hdr
,
yfs
->
page_size
);
yfs
->
page_size
);
if
(
cnt
==
-
1
||
cnt
<
yfs
->
page_size
)
{
if
(
(
cnt
<
0
)
||
((
unsigned
int
)
cnt
<
yfs
->
page_size
)
)
{
free
(
hdr
);
free
(
hdr
);
return
1
;
return
1
;
}
}
...
@@ -1355,7 +1354,7 @@ static uint8_t
...
@@ -1355,7 +1354,7 @@ static uint8_t
yaffsfs_read_spare
(
YAFFSFS_INFO
*
yfs
,
YaffsSpare
**
spare
,
TSK_OFF_T
offset
)
yaffsfs_read_spare
(
YAFFSFS_INFO
*
yfs
,
YaffsSpare
**
spare
,
TSK_OFF_T
offset
)
{
{
unsigned
char
*
spr
;
unsigned
char
*
spr
;
unsigned
in
t
cnt
;
ssize_
t
cnt
;
YaffsSpare
*
sp
;
YaffsSpare
*
sp
;
TSK_FS_INFO
*
fs
=
&
(
yfs
->
fs_info
);
TSK_FS_INFO
*
fs
=
&
(
yfs
->
fs_info
);
...
@@ -1383,7 +1382,7 @@ static uint8_t
...
@@ -1383,7 +1382,7 @@ static uint8_t
}
}
cnt
=
tsk_img_read
(
fs
->
img_info
,
offset
,
(
char
*
)
spr
,
yfs
->
spare_size
);
cnt
=
tsk_img_read
(
fs
->
img_info
,
offset
,
(
char
*
)
spr
,
yfs
->
spare_size
);
if
(
cnt
==
-
1
||
cnt
<
yfs
->
spare_size
)
{
if
(
(
cnt
<
0
)
||
((
unsigned
int
)
cnt
<
yfs
->
spare_size
)
)
{
// couldn't read sufficient bytes...
// couldn't read sufficient bytes...
if
(
spare
)
{
if
(
spare
)
{
free
(
spr
);
free
(
spr
);
...
...
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