# HG changeset patch # User Rik # Date 1584309213 25200 # Node ID 41750ce4752ca255bec57a362c46229242fbd229 # Parent 54d6f1b5fab2ee91e53bd2aaa184106bdf23c8e2 Better input validation for audioplayer (bug #57939). * audiodevinfo.cc (__player_audioplayer__): Validate that NBITS input is one of 8, 16, or 24. diff -r 54d6f1b5fab2 -r 41750ce4752c libinterp/dldfcn/audiodevinfo.cc --- a/libinterp/dldfcn/audiodevinfo.cc Fri Mar 13 15:14:49 2020 -0700 +++ b/libinterp/dldfcn/audiodevinfo.cc Sun Mar 15 14:53:33 2020 -0700 @@ -2378,16 +2378,24 @@ recorder->set_y (args(0)); recorder->set_fs (args(1).int_value ()); - switch (args.length ()) + if (args.length () > 2) { - case 3: - recorder->set_nbits (args(2).int_value ()); - break; - - case 4: - recorder->set_nbits (args(2).int_value ()); - recorder->set_id (args(3).int_value ()); - break; + // FIXME: Should be able to support 32-bit streams (bug #57939) + int nbits = args(2).int_value (); + if (nbits != 8 || nbits != 16 || nbits != 24) + error ("audioplayer: NBITS must be 8, 16, or 24"); + + switch (args.length ()) + { + case 3: + recorder->set_nbits (nbits); + break; + + case 4: + recorder->set_nbits (nbits); + recorder->set_id (args(3).int_value ()); + break; + } } if (is_function)