Skip to content

Commit

Permalink
Merge pull request #431 from zowe/artifacts14415
Browse files Browse the repository at this point in the history
Made the bytes to be encoded for base64 scheme to be divisble by 3
  • Loading branch information
JoeNemo authored Mar 6, 2024
2 parents 40fd575 + c8646d0 commit 46fcf51
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Zowe Common C Changelog

## `2.16.0`
- For correct base64 encoding scheme the buffer size is made to be divisble by 3 (#431).

## `2.15.0`
- Remove obsolete building script build_configmgr.sh (#410). (#423)

Expand Down
8 changes: 5 additions & 3 deletions c/httpserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -4637,8 +4637,9 @@ static int streamBinaryForFile2(HttpResponse *response, Socket *socket, UnixFile
if (encoding == ENCODING_CHUNKED) {
stream = makeChunkedOutputStreamInternal(response);
}

int bufferSize = FILE_STREAM_BUFFER_SIZE;

// To make bufferSize divisble by 3 for correct base64 encoding.
int bufferSize = FILE_STREAM_BUFFER_SIZE - (FILE_STREAM_BUFFER_SIZE % 3);
char *buffer = safeMalloc(bufferSize+4, "streamBinaryBuffer");
int encodedLength;

Expand Down Expand Up @@ -4710,7 +4711,8 @@ static int streamTextForFile2(HttpResponse *response, Socket *socket, UnixFile *
stream = makeChunkedOutputStreamInternal(response);
/* fallthrough */
case ENCODING_SIMPLE: {
int bufferSize = FILE_STREAM_BUFFER_SIZE;
// To make bufferSize divisble by 3 for correct base64 encoding.
int bufferSize = FILE_STREAM_BUFFER_SIZE - (FILE_STREAM_BUFFER_SIZE % 3);
char *buffer = safeMalloc(bufferSize+4, "streamTextBuffer");
char *translation = safeMalloc((2*bufferSize)+4, "streamTextConvertBuffer"); /* UTF inflation tolerance */
int encodedLength;
Expand Down

0 comments on commit 46fcf51

Please sign in to comment.