File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -182,6 +182,11 @@ impl Parser {
182182 // conv=block,unblock,ascii
183183 // conv=block conv=unblock conv=ascii
184184 let block = if let Some ( cbs) = self . cbs {
185+ // GNU dd exits when cbs is not positive.
186+ if cbs <= 0 {
187+ return Err ( ParseError :: InvalidNumber ( cbs. to_string ( ) ) ) ;
188+ }
189+
185190 match conversion {
186191 Some ( Conversion :: Ascii ) => Some ( Block :: Unblock ( cbs) ) ,
187192 Some ( _) => Some ( Block :: Block ( cbs) ) ,
@@ -231,6 +236,13 @@ impl Parser {
231236 Some ( bs) => ( bs, bs) ,
232237 } ;
233238
239+ // GNU dd exits when bs, ibs or obs are not positive.
240+ for bs in [ ibs, obs] {
241+ if bs <= 0 {
242+ return Err ( ParseError :: InvalidNumber ( bs. to_string ( ) ) ) ;
243+ }
244+ }
245+
234246 // Whether to buffer partial output blocks until they are completed.
235247 //
236248 // From the GNU `dd` documentation for the `bs=BYTES` option:
You can’t perform that action at this time.
0 commit comments