Skip to content
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

Verify utf-8 encodings when unmarshaling #413

Closed
wants to merge 1 commit into from

Conversation

liggitt
Copy link
Contributor

@liggitt liggitt commented Oct 17, 2019

To match stdlib behavior, and to ensure readString(bytes) matches readString(writeString(readString(bytes))), we need to verify utf-8 encoding when reading data, and replace invalid utf-8 runs with utf8.RuneError

Found while running https://github.com/dvyukov/go-fuzz-corpus/tree/master/json on this library

Fixes #323

@codecov
Copy link

codecov bot commented Oct 17, 2019

Codecov Report

Merging #413 into master will decrease coverage by 0.3%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #413      +/-   ##
==========================================
- Coverage   86.88%   86.58%   -0.31%     
==========================================
  Files          41       41              
  Lines        5102     5121      +19     
==========================================
+ Hits         4433     4434       +1     
- Misses        533      551      +18     
  Partials      136      136
Impacted Files Coverage Δ
iter_str.go 91.97% <100%> (+1.06%) ⬆️
reflect_struct_decoder.go 81.89% <0%> (-2.4%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 03217c3...8c3e7b9. Read the comment docs.

@liggitt liggitt closed this Mar 20, 2023
emicklei pushed a commit to emicklei/go-restful that referenced this pull request Jan 3, 2024
That module uses github.com/modern-go/reflect2 which is broken.

First, it is brittle because it relies on golang's implementation
details that are not stable across golang releases. For example,
reflect2 was broken when go 1.18 came out.

Second, reflect2 is effectively unmaintained:
  modern-go/reflect2#24 (comment)

Json-iterator itself has had correctness issues like
  json-iterator/go#413.

The Kubernetes project has mostly removed the dependency on json-iterator
in patches like
  kubernetes/kubernetes#105030.

Moreover, the Kubernetes authors found it out that json-iterator puts
a lot of load on the allocator, so even the performance gains are
questionable.

Let us remove dependencies on json-iterator and reflect2.
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.

encoding/json compatibility issues with malformed unicode strings
1 participant