Skip to content

Conversation

@mbolivar
Copy link
Contributor

@mbolivar mbolivar commented May 3, 2017

Re-implement json_escape() with a version that doesn't make a copy of the input string. Add test cases.

@nashif nashif self-assigned this May 3, 2017
@nashif nashif requested a review from lpereira May 3, 2017 23:37
Copy link
Member

@lpereira lpereira left a 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
Copy link
Member

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.

Copy link
Contributor Author

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.

Marti Bolivar added 2 commits May 4, 2017 09:47
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]>
@mbolivar
Copy link
Contributor Author

mbolivar commented May 4, 2017

Update:

  • rewrote as a for loop
  • added a test case to catch the edge condition discussed in last night's comments

@nashif nashif merged commit 88f33dc into zephyrproject-rtos:master May 8, 2017
@mbolivar mbolivar deleted the json-escape-inplace branch May 18, 2017 04:12
nashif pushed a commit that referenced this pull request Jun 29, 2021
- to get the update hal_nxp from PR #76

Signed-off-by: Lucien Zhao <[email protected]>
CristXu pushed a commit that referenced this pull request Jul 4, 2021
- to get the update hal_nxp from PR #76

Signed-off-by: Lucien Zhao <[email protected]>
frkv added a commit to frkv/zephyr that referenced this pull request Jan 28, 2025
-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]>
frkv added a commit to frkv/zephyr that referenced this pull request Feb 11, 2025
-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]>
masz-nordic pushed a commit to masz-nordic/zephyr that referenced this pull request Feb 13, 2025
… 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]>
RICCIARDI-Adrien pushed a commit to RICCIARDI-Adrien/zephyr that referenced this pull request Jun 6, 2025
… 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)
ndrs-pst added a commit to DDC-NDRS/zephyr_rtos that referenced this pull request Sep 20, 2025
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants