Git Product home page Git Product logo

Comments (6)

eeumay avatar eeumay commented on June 2, 2024

I may have fixed this issue.
Here is diff:

ubuntu@xxxxx:~/workspace/openSource/openthread$ git diff
diff --git a/src/core/coap/coap.cpp b/src/core/coap/coap.cpp
index 696d0fc83..64e148792 100644
--- a/src/core/coap/coap.cpp
+++ b/src/core/coap/coap.cpp
@@ -655,7 +655,7 @@ Error CoapBase::PrepareNextBlockRequest(Message::BlockType aType,
         }
 
         // Copy option
-        SuccessOrExit(error = iterator.ReadOptionValue(&optionBuf));
+        SuccessOrExit(error = iterator.ReadOptionValue(optionBuf));
         SuccessOrExit(error = aRequest.AppendOption(optionNumber, iterator.GetOption()->GetLength(), &optionBuf));
     }

ReadOptionValue accepts a void* or &uint64_t type,and optionBuf is a uint64_t type. Obviously, this is a typo.

from openthread.

jwhui avatar jwhui commented on June 2, 2024

@eeumay , thanks for raising this issue and working to resolve it. Would you like to submit a PR with the fix?

from openthread.

eeumay avatar eeumay commented on June 2, 2024

@eeumay , thanks for raising this issue and working to resolve it. Would you like to submit a PR with the fix?

I'm on it. I will submit a PR and I'm waiting for GitHub Actions. But for copying option correctly, optionBuf should be uint8_t array. I'm not sure how to define a fixed langth adapting to an uncertain length due to the theoretical max is too big, and I decide to use the max length of the uri path which is necessary. Do you have any advice?

from openthread.

jwhui avatar jwhui commented on June 2, 2024

I'm on it. I will submit a PR and I'm waiting for GitHub Actions. But for copying option correctly, optionBuf should be uint8_t array. I'm not sure how to define a fixed langth adapting to an uncertain length due to the theoretical max is too big, and I decide to use the max length of the uri path which is necessary. Do you have any advice?

@eeumay , good observation. I believe the length issue was present in the original contribution:

@abtink , who last updated the ReadOptionValue() method, any thoughts on how to address?

from openthread.

abtink avatar abtink commented on June 2, 2024

Using a fixed (max size) array can work but would be limited.

A more flexible (but more complex) approach can be to add a new AppendOption() flavor that directly copies the option value from a passed Option::Iterator. It can then copy the bytes from one message to another using Message::AppendBytesFromMessage(), eliminating the need for an intermediate buffer.

from openthread.

eeumay avatar eeumay commented on June 2, 2024

@jwhui @abtink Thanks for your advice.
I submit a PR to fix copying option.#9894
But it still failed that Coap parsed the previous old request (in CoapBase::PrepareNextBlockRequest()), because CoapBase::FindRelatedRequest() did return a Message appending metaData, which cannot be directly iterated. In this case, Option::Iterator::Read() would reach metaData and probably return kErrorParse.
I will open another issue to talk about it.

from openthread.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.