Fix base64 decode function
Added check for out_len nil size
This commit is contained in:
parent
78955c41ab
commit
2f3ad81959
@ -25,6 +25,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
lmemorymanager,
|
lmemorymanager,
|
||||||
strings,
|
strings,
|
||||||
|
tracer,
|
||||||
util;
|
util;
|
||||||
|
|
||||||
const
|
const
|
||||||
@ -135,7 +136,6 @@ begin
|
|||||||
dtable[uInt8(base64_enc_map[i])] := uInt8(i);
|
dtable[uInt8(base64_enc_map[i])] := uInt8(i);
|
||||||
end;
|
end;
|
||||||
dtable[uInt8('=')] := 0;
|
dtable[uInt8('=')] := 0;
|
||||||
|
|
||||||
count := 0;
|
count := 0;
|
||||||
for i := 0 to (len - 1) do begin
|
for i := 0 to (len - 1) do begin
|
||||||
if dtable[uInt8(src[i])] <> $80 then begin
|
if dtable[uInt8(src[i])] <> $80 then begin
|
||||||
@ -185,8 +185,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
if out_len <> nil then begin
|
||||||
out_len^ := uInt32(b64pos) - uInt32(output);
|
out_len^ := uInt32(b64pos) - uInt32(output);
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
b64_decode := output;
|
b64_decode := output;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -195,7 +197,9 @@ var
|
|||||||
src_len : uInt32;
|
src_len : uInt32;
|
||||||
begin
|
begin
|
||||||
src_len := stringSize(src);
|
src_len := stringSize(src);
|
||||||
|
tracer.push_trace('base64_prog.base64.begin.encode');
|
||||||
b64_encode_str := PChar(b64_encode(PuInt8(src), src_len, nil));
|
b64_encode_str := PChar(b64_encode(PuInt8(src), src_len, nil));
|
||||||
|
tracer.push_trace('base64_prog.base64.return.encode');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function b64_decode_str(src : PChar) : PChar;
|
function b64_decode_str(src : PChar) : PChar;
|
||||||
@ -203,7 +207,9 @@ var
|
|||||||
src_len : uInt32;
|
src_len : uInt32;
|
||||||
begin
|
begin
|
||||||
src_len := stringSize(src);
|
src_len := stringSize(src);
|
||||||
|
tracer.push_trace('base64_prog.base64.begin.decode');
|
||||||
b64_decode_str := PChar(b64_decode(PuInt8(src), src_len, nil));
|
b64_decode_str := PChar(b64_decode(PuInt8(src), src_len, nil));
|
||||||
|
tracer.push_trace('base64_prog.base64.return.decode');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
Loading…
x
Reference in New Issue
Block a user