Skip to content

Commit a5ea2c9

Browse files
committed
Address comments
* Fix a comment since TrackRepository only tracks metadata changes. * Error rather than panic if root version is 2^32 or above. * Add a fixme(theupdateframework#306) to add a limit on the number of root metadata fetch. Change-Id: I8adef8261108ee45630c407738372fb37e93c3b4
1 parent 027efa5 commit a5ea2c9

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

Diff for: src/client.rs

+5
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,11 @@ where
478478
// exact number is as yet unknown), then go to step 5.1.9. The value for Y is set
479479
// by the authors of the application using TUF. For example, Y may be 2^10.
480480

481+
// FIXME(#306) We do not have an upper bound on the number of root metadata we'll
482+
// fetch. This means that an attacker that's stolen the root keys could cause a client
483+
// to fall into an infinite loop (but if an attacker has stolen the root keys, the
484+
// client probably has worse problems to worry about).
485+
481486
let next_version = MetadataVersion::Number(self.tuf.trusted_root().version() + 1);
482487
let res = self
483488
.remote

Diff for: src/repository/track_repo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl Track {
5858
}
5959
}
6060

61-
/// Helper Repository wrapper that tracks all the fetches and stores for testing purposes.
61+
/// Helper Repository wrapper that tracks all the metadata fetches and stores for testing purposes.
6262
pub(crate) struct TrackRepository<R> {
6363
repo: R,
6464
tracks: Arc<Mutex<Vec<Track>>>,

Diff for: src/tuf.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,9 @@ impl<D: DataInterchange> Tuf<D> {
189189
// discard it, abort the update cycle, and report the rollback attack. On the next
190190
// update cycle, begin at step 0 and version N of the root metadata file.
191191

192-
let next_root_version = trusted_root
193-
.version()
194-
.checked_add(1)
195-
.expect("root version should be less than max u32");
192+
let next_root_version = trusted_root.version().checked_add(1).ok_or_else(|| {
193+
Error::VerificationFailure(format!("root version should be less than max u32"))
194+
})?;
196195

197196
if new_root.version() != next_root_version {
198197
return Err(Error::VerificationFailure(format!(

0 commit comments

Comments
 (0)