m4sterchain commented on code in PR #235:
URL: 
https://github.com/apache/teaclave-trustzone-sdk/pull/235#discussion_r2385460087


##########
optee-teec/src/extension.rs:
##########
@@ -57,7 +57,8 @@ impl<'a> PluginParameters<'a> {
     pub fn set_buf_from_slice(&mut self, sendslice: &[u8]) -> Result<()> {
         if self.inout.len() < sendslice.len() {
             println!("Overflow: Input length is less than output length");
-            return Err(Error::new(ErrorKind::Security));
+            self.outlen = sendslice.len();

Review Comment:
   The latest API change has side affect that causes panic in certain calling 
sequence, which could be avoided with a more elegant impl. 
   ```
   #[cfg(test)]
   mod tests {
       use super::*;
   
       #[test]
       fn test_set_buf_from_slice_overflow() {
           let mut buffer = [0u8; 8];
           let mut params = PluginParameters::new(1, 2, &mut buffer);
   
           let data = [1u8; 16];
           let result = params.set_buf_from_slice(&data);
           let s = params.get_out_slice();
           assert!(result.is_err());
       }
   }
   
   thread 'tests::test_set_buf_from_slice_overflow' panicked at ...:
   range end index 16 out of range for slice of length 8
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to