pw_string: Fix signed integer overflow

std::abs() fails for the minimum valued integer, since its absolute
value cannot be represented as a signed integer. Cast to uint64_t before
negating the value to avoid this.

Fixes: b/298647705
Change-Id: I5102122814a77653e407bc8229bc6ea3d3091fbb
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/171839
Commit-Queue: Wyatt Hepler <hepler@google.com>
Reviewed-by: Ted Pudlik <tpudlik@google.com>
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
1 file changed
tree: b2d4a413c8eb40588326330deb65ffedea811830
  1. .allstar/
  2. .vscode/
  3. build_overrides/
  4. docker/
  5. docs/
  6. pw_alignment/
  7. pw_allocator/
  8. pw_analog/
  9. pw_android_toolchain/
  10. pw_arduino_build/
  11. pw_assert/
  12. pw_assert_basic/
  13. pw_assert_log/
  14. pw_assert_tokenized/
  15. pw_assert_zephyr/
  16. pw_async/
  17. pw_async_basic/
  18. pw_base64/
  19. pw_bloat/
  20. pw_blob_store/
  21. pw_bluetooth/
  22. pw_bluetooth_hci/
  23. pw_bluetooth_profiles/
  24. pw_boot/
  25. pw_boot_cortex_m/
  26. pw_build/
  27. pw_build_info/
  28. pw_build_mcuxpresso/
  29. pw_bytes/
  30. pw_checksum/
  31. pw_chre/
  32. pw_chrono/
  33. pw_chrono_embos/
  34. pw_chrono_freertos/
  35. pw_chrono_stl/
  36. pw_chrono_threadx/
  37. pw_chrono_zephyr/
  38. pw_cli/
  39. pw_compilation_testing/
  40. pw_console/
  41. pw_containers/
  42. pw_cpu_exception/
  43. pw_cpu_exception_cortex_m/
  44. pw_crypto/
  45. pw_digital_io/
  46. pw_digital_io_mcuxpresso/
  47. pw_docgen/
  48. pw_doctor/
  49. pw_env_setup/
  50. pw_file/
  51. pw_function/
  52. pw_fuzzer/
  53. pw_hdlc/
  54. pw_hex_dump/
  55. pw_i2c/
  56. pw_i2c_linux/
  57. pw_i2c_mcuxpresso/
  58. pw_ide/
  59. pw_interrupt/
  60. pw_interrupt_cortex_m/
  61. pw_interrupt_xtensa/
  62. pw_interrupt_zephyr/
  63. pw_intrusive_ptr/
  64. pw_kvs/
  65. pw_libc/
  66. pw_log/
  67. pw_log_android/
  68. pw_log_basic/
  69. pw_log_null/
  70. pw_log_rpc/
  71. pw_log_string/
  72. pw_log_tokenized/
  73. pw_log_zephyr/
  74. pw_malloc/
  75. pw_malloc_freelist/
  76. pw_metric/
  77. pw_minimal_cpp_stdlib/
  78. pw_module/
  79. pw_multisink/
  80. pw_package/
  81. pw_perf_test/
  82. pw_persistent_ram/
  83. pw_polyfill/
  84. pw_preprocessor/
  85. pw_presubmit/
  86. pw_protobuf/
  87. pw_protobuf_compiler/
  88. pw_random/
  89. pw_result/
  90. pw_ring_buffer/
  91. pw_router/
  92. pw_rpc/
  93. pw_rpc_transport/
  94. pw_rust/
  95. pw_snapshot/
  96. pw_software_update/
  97. pw_span/
  98. pw_spi/
  99. pw_spi_mcuxpresso/
  100. pw_status/
  101. pw_stm32cube_build/
  102. pw_stream/
  103. pw_stream_shmem_mcuxpresso/
  104. pw_stream_uart_linux/
  105. pw_stream_uart_mcuxpresso/
  106. pw_string/
  107. pw_symbolizer/
  108. pw_sync/
  109. pw_sync_baremetal/
  110. pw_sync_embos/
  111. pw_sync_freertos/
  112. pw_sync_stl/
  113. pw_sync_threadx/
  114. pw_sync_zephyr/
  115. pw_sys_io/
  116. pw_sys_io_ambiq_sdk/
  117. pw_sys_io_arduino/
  118. pw_sys_io_baremetal_lm3s6965evb/
  119. pw_sys_io_baremetal_stm32f429/
  120. pw_sys_io_emcraft_sf2/
  121. pw_sys_io_mcuxpresso/
  122. pw_sys_io_pico/
  123. pw_sys_io_stdio/
  124. pw_sys_io_stm32cube/
  125. pw_sys_io_zephyr/
  126. pw_system/
  127. pw_target_runner/
  128. pw_thread/
  129. pw_thread_embos/
  130. pw_thread_freertos/
  131. pw_thread_stl/
  132. pw_thread_threadx/
  133. pw_thread_zephyr/
  134. pw_tls_client/
  135. pw_tls_client_boringssl/
  136. pw_tls_client_mbedtls/
  137. pw_tokenizer/
  138. pw_tool/
  139. pw_toolchain/
  140. pw_toolchain_bazel/
  141. pw_trace/
  142. pw_trace_tokenized/
  143. pw_transfer/
  144. pw_unit_test/
  145. pw_unit_test_zephyr/
  146. pw_varint/
  147. pw_watch/
  148. pw_web/
  149. pw_work_queue/
  150. seed/
  151. targets/
  152. third_party/
  153. ts/
  154. zephyr/
  155. .bazelignore
  156. .bazelrc
  157. .black.toml
  158. .clang-format
  159. .clang-tidy
  160. .eslintrc.cjs
  161. .git-blame-ignore-revs
  162. .gitattributes
  163. .gitignore
  164. .gn
  165. .mypy.ini
  166. .prettierignore
  167. .prettierrc.cjs
  168. .pw_ide.yaml
  169. .pylintrc
  170. activate.bat
  171. Android.bp
  172. AUTHORS
  173. bootstrap.bat
  174. bootstrap.sh
  175. BUILD.bazel
  176. BUILD.gn
  177. BUILDCONFIG.gn
  178. CMakeLists.txt
  179. jest.config.ts
  180. Kconfig.zephyr
  181. LICENSE
  182. modules.gni
  183. OWNERS
  184. package-lock.json
  185. package.json
  186. pigweed.json
  187. PIGWEED_MODULES
  188. README.md
  189. rollup.config.js
  190. tsconfig.json
  191. WORKSPACE
README.md

Pigweed

Pigweed is an open source collection of embedded-targeted libraries–or as we like to call them, modules. These modules are building blocks and infrastructure that enable faster and more reliable development on small-footprint MMU-less 32-bit microcontrollers like the STMicroelectronics STM32L452 or the Nordic nRF52832.

For more information please see our website: https://pigweed.dev/.

Links