File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- 260209.1
1+ 260810.0
Original file line number Diff line number Diff line change 2626 } ,
2727} ;
2828
29+ const MAX_HSCAN_COUNT : u32 = 5000 ;
30+
2931struct Inner {
3032 storage : Storage ,
3133}
@@ -169,6 +171,10 @@ impl StorageApi for Server {
169171 . map ( |card| Output :: Cardinality ( card as u64 ) ) ,
170172
171173 operation:: Owned :: HScan ( op) => {
174+ if op. count > MAX_HSCAN_COUNT {
175+ return Err ( Error :: invalid_argument ( ) ) ;
176+ }
177+
172178 let opts = ScanOptions :: new ( op. count as usize ) . with_cursor ( op. cursor ) ;
173179
174180 self . map_storage ( )
Original file line number Diff line number Diff line change @@ -434,6 +434,9 @@ pub enum ErrorKind {
434434 /// Internal error.
435435 Internal ,
436436
437+ /// Invalid argument.
438+ InvalidArgument ,
439+
437440 /// Transport error.
438441 Transport ,
439442
@@ -465,6 +468,11 @@ impl Error {
465468 Self :: new ( ErrorKind :: Internal )
466469 }
467470
471+ /// Creates a new [`Error`] with [`ErrorKind::InvalidArgument`].
472+ pub const fn invalid_argument ( ) -> Self {
473+ Self :: new ( ErrorKind :: InvalidArgument )
474+ }
475+
468476 pub fn with_message ( mut self , message : impl ToString ) -> Self {
469477 self . message = Some ( message. to_string ( ) ) ;
470478 self
@@ -478,7 +486,7 @@ impl Error {
478486 /// Indicates whether this [`Error`] is transient and can be retried.
479487 pub fn is_transient ( & self ) -> bool {
480488 match self . kind {
481- ErrorKind :: Unauthorized | ErrorKind :: Unknown => false ,
489+ ErrorKind :: Unauthorized | ErrorKind :: InvalidArgument | ErrorKind :: Unknown => false ,
482490 ErrorKind :: KeyspaceVersionMismatch
483491 | ErrorKind :: Timeout
484492 | ErrorKind :: Internal
Original file line number Diff line number Diff line change @@ -282,6 +282,7 @@ enum ErrorCode {
282282 Internal = 0 ,
283283 Unauthorized = 1 ,
284284 KeyspaceVersionMismatch = 2 ,
285+ InvalidArgument = 3 ,
285286}
286287
287288type Result < T , E = Error > = std:: result:: Result < T , E > ;
@@ -299,6 +300,7 @@ impl From<Error> for crate::Error {
299300 ErrorCode :: Unauthorized => ErrorKind :: Unauthorized ,
300301 ErrorCode :: KeyspaceVersionMismatch => ErrorKind :: KeyspaceVersionMismatch ,
301302 ErrorCode :: Internal => ErrorKind :: Internal ,
303+ ErrorCode :: InvalidArgument => ErrorKind :: InvalidArgument ,
302304 } ;
303305
304306 Self {
@@ -315,6 +317,7 @@ impl From<crate::ErrorKind> for ErrorCode {
315317 match kind {
316318 ErrorKind :: Unauthorized => ErrorCode :: Unauthorized ,
317319 ErrorKind :: KeyspaceVersionMismatch => ErrorCode :: KeyspaceVersionMismatch ,
320+ ErrorKind :: InvalidArgument => ErrorCode :: InvalidArgument ,
318321
319322 ErrorKind :: Internal
320323 | ErrorKind :: Timeout
You can’t perform that action at this time.
0 commit comments