Comments (3)
The problem is that base64_encode
put padding in the middle of the stream ('==').
from base64.
Hey, thanks for the report. I'm a bit baffled by this, because like you say, if the library is run inside a mutex, it should be threadsafe. In fact, it should be fairly threadsafe to start with, because the only shared mutable datastructure it uses is the codec selection structure, which is written to once on the first call. All the other functions are reentrant and do not share common data. So that can't really explain the bug.
The padding is written by base64_stream_encode_final
, just before base64_encode
returns. So I don't see a way in which it can insert those characters into the middle of a stream. What kind of IO is writeOutput
doing? It could be that the IO is not properly flushed between threads, causing the output to be interleaved.
from base64.
Before unlocking the mutex, writeOutput
adds header and trailer to the base64 data, and sends out through a socket. Now if there were incorrect flushing between threads, it shall be "all-or-nothing" fashion because of the mutex.
I'm not seeing this:
HEADER#(BASE64_1)#TRAILER HEADER#(BASE64_1)(BASE64_2)#TRAILER
But I'm seeing this:
HEADER#(BASE64_1)#TRAILER HEADER#(BASE64_2)(BASE64_3)#TRAILER
This can be easily worked around by splitting the stream at the decoder (or if there is no padding in the middle no need to split at all).
My only concern here is buffer size: I've optimized Base64Buffer
to fit 4096 bytes.
Obviously it wont be able handle more data and could cause a segfault.
from base64.
Related Issues (20)
- bin/base64: modernize the demo program
- Add a macro to calculate encoded size from raw size and vice versa
- Investigate `gf2p8affineqb` for the shuffle step
- enc: asm: add memory and flags as clobbers
- Integrate with google/oss-fuzz for continuous fuzz testing
- Create release 0.5.1
- Codec detection doesnโt work in test_base64 on musl libc HOT 3
- v0.5.1 breaks `base64 -d` on Alpine Linux (musl libc) HOT 15
- Build of 0.5.1 broken with MinGW HOT 15
- I made a online base64 decoder tool. We can use it HOT 1
- Simplify codepath selection HOT 4
- build failure using mingw32: `error: 'asm' operand has impossible constraints` HOT 4
- CMakeLists: update version to 0.5.2
- bin/base64: add command line options for decoding
- Add `BASE64_FORCE_INLINE` macro to always inline inner loop functions
- Decoding error on Windows (CRLF?) HOT 18
- Codepage error on Windows HOT 2
- Build fails on macOS: `make: objcopy: No such file or directory` HOT 2
- Add installation guide for lib HOT 2
- error: implicit declaration of function 'bit' is invalid in C99 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from base64.