This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 791e223001ae8b122426b230998c3e211faab3cc
Author: makejian <[email protected]>
AuthorDate: Mon Jun 9 21:00:05 2025 +0800

    crypto/cryptosoft: fix buffer pointer
    
    Fix issue where input buffer pointer was modified during crypto operations.
    
    Ensures original buffer pointer remains valid for the caller.
    
    Signed-off-by: makejian <[email protected]>
---
 crypto/cryptosoft.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/crypto/cryptosoft.c b/crypto/cryptosoft.c
index bf4de047e3e..fd4f01cb8b7 100644
--- a/crypto/cryptosoft.c
+++ b/crypto/cryptosoft.c
@@ -61,6 +61,7 @@ int swcr_id = -1;
 int swcr_encdec(FAR struct cryptop *crp, FAR struct cryptodesc *crd,
                 FAR struct swcr_data *sw, caddr_t buf)
 {
+  FAR char *output;
   unsigned char blk[EALG_MAX_BLOCK_LEN];
   FAR unsigned char *iv;
   FAR unsigned char *ivp;
@@ -117,6 +118,7 @@ int swcr_encdec(FAR struct cryptop *crp, FAR struct 
cryptodesc *crd,
   i = crd->crd_len;
 
   buf = buf + crd->crd_skip;
+  output = crp->crp_dst;
   while (i > 0)
     {
       bcopy(buf, blk, exf->blocksize);
@@ -173,8 +175,8 @@ int swcr_encdec(FAR struct cryptop *crp, FAR struct 
cryptodesc *crd,
           ivp = nivp;
         }
 
-      bcopy(blk, crp->crp_dst, exf->blocksize);
-      crp->crp_dst += exf->blocksize;
+      bcopy(blk, output, exf->blocksize);
+      output += exf->blocksize;
 
       i -= blks;
 

Reply via email to