ditch problematic HWPFile::Read4b variant

Change-Id: Ied3603d8f96e15013f657fc5d8150969ae3b808d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123534
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara 2021-10-12 20:59:26 +01:00
parent ec1e3c7751
commit 4fed3b2ed1
6 changed files with 8 additions and 17 deletions

View file

@ -98,7 +98,7 @@ bool HWPPara::Read(HWPFile & hwpf, unsigned char flag)
hwpf.Read2b(&nline, 1);
hwpf.Read1b(contain_cshape);
hwpf.Read1b(etcflag);
hwpf.Read4b(&ctrlflag, 1);
hwpf.Read4b(ctrlflag);
hwpf.Read1b(pstyno);
/* Paragraph representative character */

View file

@ -104,7 +104,7 @@ class DLLEXPORT HWPPara
/**
* Checks the special characters in the paragraph
*/
tools::ULong ctrlflag;
uint ctrlflag;
unsigned char pstyno;
std::shared_ptr<CharShape> cshape; /* When characters are all the same shape */
std::shared_ptr<ParaShape> pshape; /* if reuse flag is 0, */

View file

@ -98,7 +98,7 @@ void OlePicture::Read(HWPFile & hwpf)
return;
// We process only FILESTG_SIGNATURE_NORMAL.
hwpf.Read4b(&signature, 1);
hwpf.Read4b(signature);
if (signature != FILESTG_SIGNATURE_NORMAL)
return;
#ifdef _WIN32

View file

@ -158,12 +158,6 @@ size_t HWPFile::Read2b(void *ptr, size_t nmemb)
return hiodev ? hiodev->read2b(ptr, nmemb) : 0;
}
void HWPFile::Read4b(void *ptr, size_t nmemb)
{
if (hiodev)
hiodev->read4b(ptr, nmemb);
}
size_t HWPFile::ReadBlock(void *ptr, size_t size)
{
return hiodev ? hiodev->readBlock(ptr, size) : 0;

View file

@ -139,10 +139,7 @@ class DLLEXPORT HWPFile
* Reads nmemb short type array from HIODev
*/
size_t Read2b(void *ptr, size_t nmemb);
/**
* Reads nmemb long type array from HIODev
*/
void Read4b( void *ptr, size_t nmemb );
/**
* Reads some bytes from HIODev not regarding endian's way
* @param size Amount for reading

View file

@ -46,7 +46,7 @@ bool HBox::Read(HWPFile & )
bool SkipData::Read(HWPFile & hwpf)
{
uint data_block_len;
hwpf.Read4b(&data_block_len, 1);
hwpf.Read4b(data_block_len);
hchar dummy;
if (!hwpf.Read2b(dummy))
@ -73,7 +73,7 @@ bool FieldCode::Read(HWPFile & hwpf)
if (!hwpf.Read2b(dummy))
return false;
hwpf.ReadBlock(&type, 2);
hwpf.Read4b(reserved1.data(), 1);
hwpf.ReadBlock(reserved1.data(), 4);
if (!hwpf.Read2b(location_info))
return false;
hwpf.ReadBlock(reserved2.data(), 22);
@ -123,7 +123,7 @@ bool Bookmark::Read(HWPFile & hwpf)
{
uint len;
hwpf.Read4b(&len, 1);
hwpf.Read4b(len);
if (!hwpf.Read2b(dummy))
return false;
@ -402,7 +402,7 @@ bool Picture::Read(HWPFile & hwpf)
}
hwpf.AddBox(this);
hwpf.Read4b(&follow_block_size, 1);
hwpf.Read4b(follow_block_size);
//when fuzzing with a max len set, max decompress to 10 times that limit
static size_t nMaxAllowedDecompression = [](const char* pEnv) { size_t nRet = pEnv ? std::atoi(pEnv) : 0; return nRet * 10; }(std::getenv("FUZZ_MAX_INPUT_LEN"));