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
6959fd5b
Commit
6959fd5b
authored
6 years ago
by
Brian Carrier
Browse files
Options
Downloads
Patches
Plain Diff
make new version of test_root that is not from other licensed code. Closes #1251
parent
8b15b4f5
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/ext2fs.c
+22
-10
22 additions, 10 deletions
tsk/fs/ext2fs.c
with
22 additions
and
10 deletions
tsk/fs/ext2fs.c
+
22
−
10
View file @
6959fd5b
...
@@ -55,8 +55,6 @@ debug_print_buf(unsigned char *buf, int len)
...
@@ -55,8 +55,6 @@ debug_print_buf(unsigned char *buf, int len)
/** \internal
/** \internal
test_root - tests to see if a is power of b
test_root - tests to see if a is power of b
Adapted from E2fsprogs sparse.c
Super blocks are only in block groups that are powers of 3,5, and 7
@param a the number being investigated
@param a the number being investigated
@param b the root
@param b the root
@return 1 if a is a power of b, otherwise 0
@return 1 if a is a power of b, otherwise 0
...
@@ -64,15 +62,25 @@ debug_print_buf(unsigned char *buf, int len)
...
@@ -64,15 +62,25 @@ debug_print_buf(unsigned char *buf, int len)
static
uint8_t
static
uint8_t
test_root
(
uint32_t
a
,
uint32_t
b
)
test_root
(
uint32_t
a
,
uint32_t
b
)
{
{
if
(
a
==
0
)
if
(
a
==
0
)
{
return
1
;
return
(
b
==
0
);
while
(
1
)
{
}
if
(
a
==
1
)
else
if
(
b
==
0
)
{
return
1
;
return
0
;
if
(
a
%
b
)
return
0
;
a
=
a
/
b
;
}
}
else
if
(
a
==
1
)
{
return
(
b
==
1
);
}
else
if
(
b
==
1
)
{
return
0
;
}
// keep on multiplying b by itself
uint32_t
b2
;
for
(
b2
=
b
;
b2
<
a
;
b2
*=
b
)
{}
// was it an exact match?
return
(
b2
==
a
);
}
}
/** \internal
/** \internal
...
@@ -86,6 +94,10 @@ ext2fs_bg_has_super(uint32_t feature_ro_compat, uint32_t group_block)
...
@@ -86,6 +94,10 @@ ext2fs_bg_has_super(uint32_t feature_ro_compat, uint32_t group_block)
if
(
!
(
feature_ro_compat
&
EXT2FS_FEATURE_RO_COMPAT_SPARSE_SUPER
))
if
(
!
(
feature_ro_compat
&
EXT2FS_FEATURE_RO_COMPAT_SPARSE_SUPER
))
return
1
;
return
1
;
if
(
group_block
==
0
)
return
1
;
// Super blocks are only in block groups that are powers of 3,5, and 7
if
(
test_root
(
group_block
,
3
)
||
(
test_root
(
group_block
,
5
))
||
if
(
test_root
(
group_block
,
3
)
||
(
test_root
(
group_block
,
5
))
||
test_root
(
group_block
,
7
))
test_root
(
group_block
,
7
))
return
1
;
return
1
;
...
...
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