-
Couldn't load subscription status.
- Fork 8.1k
json: don't copy strings while escaping #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
json: don't copy strings while escaping #76
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a nitpick.
lib/json/json.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick, but could be a for (; next != str; next--) instead. Can remove the last few lines in the loop body.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried and failed to think of a way to do it without while(1) / break. The edge cases are a little tricky.
The way you suggest won't work if *len == 1 and the character at str[0] needs escaping, for example.
Currently, json_escape() allocates a temporary buffer on the stack that's the size of the string being escaped. Stack space is precious and longer JSON strings can run into the hundreds of bytes, so re-implement this routine to escape in place. Signed-off-by: Marti Bolivar <[email protected]>
These all pass. Signed-off-by: Marti Bolivar <[email protected]>
|
Update:
|
- to get the update hal_nxp from PR #76 Signed-off-by: Lucien Zhao <[email protected]>
- to get the update hal_nxp from PR #76 Signed-off-by: Lucien Zhao <[email protected]>
-Update hostap to PR zephyrproject-rtos#76 which adds support for CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG instead of relying on legacy Mbed TLS ctr_drbg and entropy APIs. This change is in line with PSA crypto entropy changes in Zephyr happening with TinyCrypt deprecation and advancement of PSA crypto mechanisms -Remove defconfigs for currently sets the Kconfigs: -CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG -CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG_ALLOW_NON_CSPRNG Signed-off-by: Frank Audun Kvamtrø <[email protected]>
-Update hostap to PR zephyrproject-rtos#76 which adds support for CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG instead of relying on legacy Mbed TLS ctr_drbg and entropy APIs. This change is in line with PSA crypto entropy changes in Zephyr happening with TinyCrypt deprecation and advancement of PSA crypto mechanisms -Remove defconfigs for currently sets the Kconfigs: -CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG -CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG_ALLOW_NON_CSPRNG Signed-off-by: Frank Audun Kvamtrø <[email protected]>
… updates -Update hostap to PR zephyrproject-rtos#76 which adds support for CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG instead of relying on legacy Mbed TLS ctr_drbg and entropy APIs. This change is in line with PSA crypto entropy changes in Zephyr happening with TinyCrypt deprecation and advancement of PSA crypto mechanisms -Remove defconfigs for currently sets the Kconfigs: -CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG -CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG_ALLOW_NON_CSPRNG Upstream PR #: 84517 Signed-off-by: Frank Audun Kvamtrø <[email protected]>
… updates -Update hostap to PR zephyrproject-rtos#76 which adds support for CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG instead of relying on legacy Mbed TLS ctr_drbg and entropy APIs. This change is in line with PSA crypto entropy changes in Zephyr happening with TinyCrypt deprecation and advancement of PSA crypto mechanisms -Remove defconfigs for currently sets the Kconfigs: -CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG -CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG_ALLOW_NON_CSPRNG Upstream PR #: 84517 Signed-off-by: Frank Audun Kvamtrø <[email protected]> (cherry picked from commit cf0873a)
# Conflicts: # drivers/counter/counter_ll_stm32_timer.c # drivers/flash/flash_esp32.c # drivers/pwm/pwm_stm32.c # drivers/sensor/st/qdec_stm32/qdec_stm32.c
Re-implement json_escape() with a version that doesn't make a copy of the input string. Add test cases.