@@ -625,7 +625,10 @@ pub fn empty_range_to_sql(buf: &mut Vec<u8>) {
625625}
626626
627627/// Serializes a range value.
628- pub fn range_to_sql < F , G > ( lower : F , upper : G , buf : & mut Vec < u8 > ) -> Result < ( ) , Box < Error + Sync + Send > >
628+ pub fn range_to_sql < F , G > ( lower : F ,
629+ upper : G ,
630+ buf : & mut Vec < u8 > )
631+ -> Result < ( ) , Box < Error + Sync + Send > >
629632 where F : FnOnce ( & mut Vec < u8 > ) -> Result < RangeBound < IsNull > , Box < Error + Sync + Send > > ,
630633 G : FnOnce ( & mut Vec < u8 > ) -> Result < RangeBound < IsNull > , Box < Error + Sync + Send > >
631634{
@@ -701,11 +704,19 @@ pub fn range_from_sql<'a>(mut buf: &'a [u8]) -> Result<Range<'a>, Box<Error + Sy
701704 let lower = try!( read_bound ( & mut buf, tag, RANGE_LOWER_UNBOUNDED , RANGE_LOWER_INCLUSIVE ) ) ;
702705 let upper = try!( read_bound ( & mut buf, tag, RANGE_UPPER_UNBOUNDED , RANGE_UPPER_INCLUSIVE ) ) ;
703706
707+ if !buf. is_empty ( ) {
708+ return Err ( "invalid message size" . into ( ) ) ;
709+ }
710+
704711 Ok ( Range :: Nonempty ( lower, upper) )
705712}
706713
707714#[ inline]
708- fn read_bound < ' a > ( buf : & mut & ' a [ u8 ] , tag : u8 , unbounded : u8 , inclusive : u8 ) -> Result < RangeBound < Option < & ' a [ u8 ] > > , Box < Error + Sync + Send > > {
715+ fn read_bound < ' a > ( buf : & mut & ' a [ u8 ] ,
716+ tag : u8 ,
717+ unbounded : u8 ,
718+ inclusive : u8 )
719+ -> Result < RangeBound < Option < & ' a [ u8 ] > > , Box < Error + Sync + Send > > {
709720 if tag & unbounded != 0 {
710721 Ok ( RangeBound :: Unbounded )
711722 } else {
0 commit comments