Skip to content

Commit 00d0f9e

Browse files
committed
Add a bounds check in IpAddr RawFromSql impl
1 parent afc4b09 commit 00d0f9e

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/types/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,9 @@ impl RawFromSql for IpAddr {
548548
let _bits = try!(raw.read_u8());
549549
let _is_cidr = try!(raw.read_u8());
550550
let nb = try!(raw.read_u8());
551+
if nb > 16 {
552+
return Err(Error::BadData);
553+
}
551554
let mut buf: &mut [u8] = &mut [0u8, ..16];
552555
try!(raw.read_at_least(nb as uint, buf));
553556
let mut buf: &[u8] = buf;

0 commit comments

Comments
 (0)