Change:
Seems to be a reroll . I have some idea how to fix it, will try to draft a pull request later, but it basically requires checking the sign of the , ging if required and casting to , and using or . I will divide into cases to demonstrate that this is required, to save repeating phrases, I will use the following notation: S means , L means ; P means , N means ; O+ means we will notice bads by checking OF on add (), O- means we will notice them by checking OF on sub ( after ), Z+ means we will notice by adding as and making sure result is non-negative, Z- is making sure it is negative, D+ mean we will notice bads by asserting OF is set on add (), D- is likewise for sub (). Note the we don't need to consider , because after and we still get the right, large, positive number. So, we have the following cases and appropriate checks that spot trouble: SP -O+Z+D- (there's never a problem, but the others false-positive) LP -O+Z-D- (but D- requires also that the result is non-zero). SN -O-Z+D+ LN -O-D+ (there's never a problem, but the others false-positive) Overall, we see that there is no one test which works for all cases, and a minimum of two cases (and tests) yields the solution described above.
Thanks for the report! I'd definitely believe that the exact implementation here is slightly wrong and could use some tweaking.
I wrote a test that should fail and an implementation that should fix, just waiting for build & tests to finish on my machine before PR. Edit: PR

Discussion:
#[stable(feature = "rust1", since = "1.0.0")] impl<T> io::Seek for Cursor<T> where T: AsRef<[u8]> { fn seek(&mut self, style: SeekFrom) -> io::Result<u64> { <del> let pos = match style { SeekFrom::Start(n) => { self.pos = n; return Ok(n) } SeekFrom::End(n) => self.inner.as_ref().len() as i64 + n, SeekFrom::Current(n) => self.pos as i64 + n, </del> <ins> let (base_pos, offset) = match style { SeekFrom::Start(n) => { self.pos = n; return Ok(n); } SeekFrom::End(n) => (self.inner.as_ref().len() as u64, n), SeekFrom::Current(n) => (self.pos, n), </ins> }; <del> if pos < 0 { Err(Error::new(ErrorKind::InvalidInput, "invalid seek to a negative position")) </del> <ins> let new_pos = if offset >= 0 { base_pos.checked_add(offset as u64) </ins> } else { <del> self.pos = pos as u64; Ok(self.pos) </del> <ins> base_pos.checked_sub((offset.wrapping_neg()) as u64) }; match new_pos { Some(n) => {self.pos = n; Ok(self.pos)} None => Err(Error::new(ErrorKind::InvalidInput, "invalid seek to a negative or overflowing position")) </ins> } } }

} #[test] <ins> fn seek_past_i64() { let buf = [0xff]; let mut r = Cursor::new(&buf[..]); assert_eq!(r.seek(SeekFrom::Start(6)).unwrap(), 6); assert_eq!(r.seek(SeekFrom::Current(0x7ffffffffffffff0)).unwrap(), 0x7ffffffffffffff6); assert_eq!(r.seek(SeekFrom::Current(0x10)).unwrap(), 0x8000000000000006); assert_eq!(r.seek(SeekFrom::Current(0)).unwrap(), 0x8000000000000006); assert!(r.seek(SeekFrom::Current(0x7ffffffffffffffd)).is_err()); assert_eq!(r.seek(SeekFrom::Current(-0x8000000000000000)).unwrap(), 6); let mut r = Cursor::new(vec![10]); assert_eq!(r.seek(SeekFrom::Start(6)).unwrap(), 6); assert_eq!(r.seek(SeekFrom::Current(0x7ffffffffffffff0)).unwrap(), 0x7ffffffffffffff6); assert_eq!(r.seek(SeekFrom::Current(0x10)).unwrap(), 0x8000000000000006); assert_eq!(r.seek(SeekFrom::Current(0)).unwrap(), 0x8000000000000006); assert!(r.seek(SeekFrom::Current(0x7ffffffffffffffd)).is_err()); assert_eq!(r.seek(SeekFrom::Current(-0x8000000000000000)).unwrap(), 6); let mut buf = [0]; let mut r = Cursor::new(&mut buf[..]); assert_eq!(r.seek(SeekFrom::Start(6)).unwrap(), 6); assert_eq!(r.seek(SeekFrom::Current(0x7ffffffffffffff0)).unwrap(), 0x7ffffffffffffff6); assert_eq!(r.seek(SeekFrom::Current(0x10)).unwrap(), 0x8000000000000006); assert_eq!(r.seek(SeekFrom::Current(0)).unwrap(), 0x8000000000000006); assert!(r.seek(SeekFrom::Current(0x7ffffffffffffffd)).is_err()); assert_eq!(r.seek(SeekFrom::Current(-0x8000000000000000)).unwrap(), 6); let mut r = Cursor::new(vec![10].into_boxed_slice()); assert_eq!(r.seek(SeekFrom::Start(6)).unwrap(), 6); assert_eq!(r.seek(SeekFrom::Current(0x7ffffffffffffff0)).unwrap(), 0x7ffffffffffffff6); assert_eq!(r.seek(SeekFrom::Current(0x10)).unwrap(), 0x8000000000000006); assert_eq!(r.seek(SeekFrom::Current(0)).unwrap(), 0x8000000000000006); assert!(r.seek(SeekFrom::Current(0x7ffffffffffffffd)).is_err()); assert_eq!(r.seek(SeekFrom::Current(-0x8000000000000000)).unwrap(), 6); } #[test] </ins> fn seek_before_0() { let buf = [0xff]; let mut r = Cursor::new(&buf[..]);