Compare commits

..

22 Commits

Author SHA1 Message Date
3cb727f8ac Merge pull request #566 from ONLYOFFICE/fix/v6.2.2-fix-bugs
fix bug #49434;...
2021-04-02 12:13:11 +03:00
7f7510b5b3 fix bug #49434
fix bug #49429
fix bug #49202
2021-04-02 12:06:47 +03:00
cd2a46a163 Merge pull request #561 from ONLYOFFICE/fix/v6.2.2-fix-bugs
fix bugs y
2021-03-31 17:42:51 +03:00
6f8c741d5e Merge branch hotfix/v6.2.1 into master 2021-03-31 11:12:47 +00:00
ce173dc575 fix bugs 2021-03-27 10:20:57 +03:00
ec1ef9b006 fix issues #1191 (#548) 2021-03-24 12:17:14 +03:00
31b196840b Merge remote-tracking branch 'origin/master' into hotfix/v6.2.1 2021-03-22 11:43:27 +03:00
ddbb99414f Merge branch release/v6.2.0 into master 2021-03-18 10:17:58 +00:00
af5329264e fix bug #49040 (#537) 2021-03-15 22:11:34 +03:00
fa9a2ed203 Merge branch release/v6.2.0 into master 2021-03-15 15:25:29 +00:00
8da8ad22d0 Merge pull request #526 from ONLYOFFICE/fix/v6.2.0-fix-bugs
fix bug #49015
2021-03-09 20:07:45 +03:00
140d86b7ec fix bug #49015 2021-03-09 20:02:16 +03:00
d57b9f975a Merge pull request #525 from ONLYOFFICE/fix/k620
Change interface of signer class
2021-03-09 17:41:26 +03:00
80f51fa151 . 2021-03-09 16:26:19 +03:00
ad1bf1def6 Merge pull request #523 from ONLYOFFICE/fix/k620
Fix/k620
2021-03-05 16:21:35 +03:00
d9c6ade2d9 Fix previous commit 2021-03-05 16:17:59 +03:00
448dc65550 Fix bugs with signing 2021-03-05 16:11:15 +03:00
d907d53a16 Merge pull request #516 from ONLYOFFICE/fix/v6.2.0-fix-bugs
Fix/v6.2.0 fix bugs
2021-03-03 11:45:56 +03:00
f8211f9aa6 x2t - fix vml shape 2021-03-03 11:40:27 +03:00
10dde7837b fix bug #47039 2021-03-03 11:18:43 +03:00
2a5a5df225 Merge branch release/v6.2.0 into master 2021-03-01 08:42:25 +00:00
8e7deaa1bc Merge branch hotfix/v6.1.1 into master 2021-01-28 08:12:35 +00:00
20 changed files with 136 additions and 60 deletions

View File

@ -80,7 +80,7 @@ public:
}
void WriteUInt16(unsigned short val)
{
if (m_Data)
if (m_Data && (m_Position + sizeof(unsigned short) <= m_Size))
{
((unsigned short *)(m_Data + m_Position))[0] = val;
m_Position += sizeof(unsigned short);
@ -113,7 +113,7 @@ public:
}
void WriteInt32(_INT32 val)
{
if (m_Data)
if (m_Data && (m_Position + sizeof(_INT32) <= m_Size))
{
((_INT32 *)(m_Data + m_Position))[0] = val;
m_Position += sizeof(_INT32);
@ -133,7 +133,7 @@ public:
}
void WriteByte(unsigned char val)
{
if (m_Data)
if (m_Data && (m_Position + 1 <= m_Size))
{
m_Data[m_Position] = val;
m_Position += 1;
@ -141,7 +141,7 @@ public:
}
void WriteUInt32(_UINT32 val)
{
if (m_Data)
if (m_Data && (m_Position + sizeof(_UINT32) <= m_Size))
{
((_UINT32 *)(m_Data + m_Position))[0] = val;
m_Position += sizeof(_UINT32);
@ -190,7 +190,7 @@ public:
}
void WriteBytes(unsigned char* pData, int size)
{
if (m_Data)
if (m_Data && (m_Position + size <= m_Size))
{
memcpy(m_Data + m_Position, pData, size);
m_Position += size;

View File

@ -352,10 +352,10 @@ namespace DocFileFormat
case sprmOldSCcolumns:
case sprmSCcolumns:
{
m_nColumns = static_cast<int> (FormatUtils::BytesToInt16 (iter->Arguments, 0, iter->argumentsSize) + 1);
m_nColumns = static_cast<int> (FormatUtils::BytesToInt16 (iter->Arguments, 0, iter->argumentsSize) + 1);
RELEASEARRAYOBJECTS (m_arrSpace);
m_arrSpace = new short [m_nColumns];
m_arrSpace = new short [m_nColumns];
appendValueAttribute (&cols, L"w:num", FormatUtils::IntToWideString (m_nColumns));
}
@ -388,10 +388,13 @@ namespace DocFileFormat
if (m_nColumns)
{
if (NULL == m_arrSpace)
m_arrSpace = new short[m_nColumns];
m_arrSpace = new short[m_nColumns];
unsigned char nInd = iter->Arguments[0];
m_arrSpace [nInd] = FormatUtils::BytesToInt16 (iter->Arguments, 1, iter->argumentsSize);
unsigned char nInd = iter->Arguments[0];
if (nInd < m_nColumns)
{
m_arrSpace[nInd] = FormatUtils::BytesToInt16(iter->Arguments, 1, iter->argumentsSize);
}
}
}break;

View File

@ -49,7 +49,7 @@ namespace cpdoccore {
namespace odf_writer {
static int style_family_counts_[26]={};//согласно количеству разных стилей
static int style_family_counts_[1024]={};//согласно количеству разных стилей
void calc_paragraph_properties_content(std::vector<style_paragraph_properties*> & parProps, paragraph_format_properties * result)

View File

@ -88,7 +88,7 @@ PptxConverter::PptxConverter(const std::wstring & path, bool bTemplate)
pptx_document = new PPTX::Document();
if (!pptx_document->isValid(oox_path.GetPath())) // true ???
{
delete pptx_document;
delete pptx_document; pptx_document = NULL;
return;
}
@ -97,7 +97,7 @@ PptxConverter::PptxConverter(const std::wstring & path, bool bTemplate)
smart_ptr<PPTX::Presentation> presentation_ptr = pptx_document->Get(OOX::Presentation::FileTypes::Presentation).smart_dynamic_cast<PPTX::Presentation>();
if (!presentation_ptr.is_init())
{
delete pptx_document;
delete pptx_document; pptx_document = NULL;
return;
}
presentation = presentation_ptr.GetPointer();

View File

@ -68,14 +68,18 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream*
oMetaFile.SetHeader(NULL, 0);
BYTE* pData = new BYTE[oHeader.RecLen - lOffset];
pStream->read(pData, oHeader.RecLen - lOffset);
if (pDecryptor)
int nDataSize = oHeader.RecLen - lOffset;
BYTE* pData = (nDataSize > 0 && nDataSize < 0xffffff ) ? (new BYTE[nDataSize]) : NULL;
if (pData)
{
pDecryptor->Decrypt((char*)pData, oHeader.RecLen - lOffset, 0);
pStream->read(pData, oHeader.RecLen - lOffset);
if (pDecryptor)
{
pDecryptor->Decrypt((char*)pData, oHeader.RecLen - lOffset, 0);
}
oMetaFile.SetData(pData, oMetaHeader.cbSave, oMetaHeader.cbSize, (bool)(oMetaHeader.compression != 0xFE));
}
oMetaFile.SetData(pData, oMetaHeader.cbSave, oMetaHeader.cbSize, (bool)(oMetaHeader.compression != 0xFE) );
}break;
case RECORD_TYPE_ESCHER_BLIP_WMF:
{

View File

@ -104,6 +104,7 @@ public:
else
{
delete []pData;
pData = NULL;
}
}
//if (pDecryptor)

View File

@ -2068,6 +2068,9 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C
oShapeElem.m_pShape->getBaseShape()->m_oPath.SetCoordsize(21600, 21600);
}
if (pPPTShape->m_oSignatureLine.IsInit())
pPPTShape->m_eType = PPTShapes::ShapeType::sptCFrame;
if (pPPTShape->m_eType == PPTShapes::sptCTextBox)
{
bTextBox = true;
@ -4599,8 +4602,8 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils
}else
{
//stretch ??? bug 28238
pBlipFill->stretch = new PPTX::Logic::Stretch();
pBlipFill->stretch.Init();
pBlipFill->stretch->fillRect.Init();
}
std::wstring strCropT = oNodeFillID.GetAttribute(L"croptop");

View File

@ -228,9 +228,13 @@ namespace NSBinPptxRW
std::wstring strExts = _T(".jpg");
//use GetFileName to avoid defining '.' in the directory as extension
std::wstring strFileName = NSFile::GetFileName(strInput);
int nIndexExt = (int)strFileName.rfind(wchar_t('.'));
if (-1 != nIndexExt)
strExts = strFileName.substr(nIndexExt);
int sizeExt = (int)strFileName.rfind(wchar_t('.'));
if (-1 != sizeExt)
{
strExts = strFileName.substr(sizeExt);
sizeExt = (int)strFileName.length() - sizeExt;
}
else sizeExt = 0;
int typeAdditional = 0;
std::wstring strAdditional;
@ -238,14 +242,14 @@ namespace NSBinPptxRW
int nDisplayType = IsDisplayedImage(strInput);
size_t nFileNameLength = strFileName.length();
if (0 != nDisplayType && nFileNameLength > 4)
if (0 != nDisplayType && nFileNameLength > sizeExt)
{
OOX::CPath oPath = strInput;
std::wstring strFolder = oPath.GetDirectory();
std::wstring strFileName = oPath.GetFilename();
strFileName.erase(strFileName.length() - 4, 4);
strFileName.erase(strFileName.length() - sizeExt, sizeExt);
if(0 != (nDisplayType & 1))
{
@ -682,7 +686,13 @@ namespace NSBinPptxRW
{
while (nNewSize >= m_lSize)
{
m_lSize *= 2;
unsigned int lSize = m_lSize * 2;
if (lSize < m_lSize)
{
m_lSize = nNewSize;
break;
}
m_lSize = lSize;
}
BYTE* pNew = new BYTE[m_lSize];
@ -696,8 +706,8 @@ namespace NSBinPptxRW
}
else
{
m_lSize = 1024 * 1024; // 1Mb
m_pStreamData = new BYTE[m_lSize];
m_lSize = 1024 * 1024; // 1Mb
m_pStreamData = new BYTE[m_lSize];
m_lPosition = 0;
m_pStreamCur = m_pStreamData;

View File

@ -325,8 +325,7 @@ namespace PPTX
if (false == detectImageExtension.empty())
{
if (sImageExtension.empty())
sImageExtension = detectImageExtension;
sImageExtension = detectImageExtension;
//папки media может не быть в случае, когда все картинки base64(поскольку файл временный, папку media не создаем)
std::wstring tempFilePath = pReader->m_strFolder + FILE_SEPARATOR_STR;

View File

@ -1395,7 +1395,8 @@ namespace PPTX
{
std::wstring strPenAttr = _T("");
nullable<ShapeStyle> pShapeStyle;
CalculateLine(spPr, pShapeStyle, oTheme, oClrMap, strPenAttr, strNodeVal, bOle);
CalculateLine(pWriter->m_lDocType, spPr, pShapeStyle, oTheme, oClrMap, strPenAttr, strNodeVal, bOle);
pWriter->WriteString(strPenAttr);
}

View File

@ -607,7 +607,8 @@ namespace PPTX
SimpleTypes::CShapeType<> ooxPrst = SimpleTypes::CShapeType<>(lpGeom.prst.get());
vmlPrst = OOX::PrstGeom2VmlShapeType( ooxPrst.GetValue());
}
else if (bSignature) vmlPrst = SimpleTypes::Vml::sptPictureFrame;
if (spPr.xfrm.is_init())
{
if (spPr.xfrm->offX.is_init()) dL = *spPr.xfrm->offX;
@ -631,8 +632,8 @@ namespace PPTX
std::wstring strFillNode;
std::wstring strStrokeNode;;
CalculateFill(spPr, style, oTheme, oClrMap, strFillAttr, strFillNode, false, bSignature);
CalculateLine(spPr, style, oTheme, oClrMap, strStrokeAttr, strStrokeNode, false);
CalculateFill(pWriter->m_lDocType, spPr, style, oTheme, oClrMap, strFillAttr, strFillNode, false, bSignature);
CalculateLine(pWriter->m_lDocType, spPr, style, oTheme, oClrMap, strStrokeAttr, strStrokeNode, false);
pWriter->StartNode(L"v:shape");
@ -763,7 +764,7 @@ namespace PPTX
pWriter->WriteString(*strTextBoxShape); //??? todooo -> oTextBoxShape
pWriter->EndNode(L"v:textbox");
}
if (spPr.Fill.m_type == UniFill::blipFill)
if (strFillNode.empty() && spPr.Fill.m_type == UniFill::blipFill)
{
BlipFill& blipFill = spPr.Fill.as<BlipFill>();
@ -796,7 +797,7 @@ namespace PPTX
void Shape::toXmlWriterVMLBackground(NSBinPptxRW::CXmlWriter *pWriter, NSCommon::smart_ptr<PPTX::Theme>& oTheme, NSCommon::smart_ptr<PPTX::Logic::ClrMap>& oClrMap)
{
std::wstring strFillAttr, strFillNode;
CalculateFill(spPr, style, oTheme, oClrMap, strFillAttr, strFillNode, false);
CalculateFill(pWriter->m_lDocType, spPr, style, oTheme, oClrMap, strFillAttr, strFillNode, false);
pWriter->StartNode(L"v:background");

View File

@ -61,7 +61,7 @@ namespace PPTX
return L"#" + sstream.str();
}
void CalculateFill(PPTX::Logic::SpPr& oSpPr, nullable<ShapeStyle>& pShapeStyle, NSCommon::smart_ptr<PPTX::Theme>& oTheme,
void CalculateFill(BYTE lDocType, PPTX::Logic::SpPr& oSpPr, nullable<ShapeStyle>& pShapeStyle, NSCommon::smart_ptr<PPTX::Theme>& oTheme,
NSCommon::smart_ptr<PPTX::Logic::ClrMap>& oClrMap, std::wstring& strAttr, std::wstring& strNode, bool bOle, bool bSignature)
{
PPTX::Logic::UniFill fill;
@ -115,18 +115,25 @@ namespace PPTX
}
std::wstring strId = oBlip.blip->embed->ToString();
if (XMLWRITER_DOC_TYPE_XLSX == lDocType)
{
strId = L"o:relid=\"" + strId + L"\"";
}
else
{
strId = L"r:id=\"" + strId + L"\"";
}
if (bOle || bSignature)
{
strAttr = L" filled=\"f\"";
strNode = L"<v:imagedata r:id=\"" + strId + L"\" o:title=\"\" />";
strNode = L"<v:imagedata " + strId + L" o:title=\"\" />";
}
else
{
if (oBlip.tile.is_init())
strNode = L"<v:fill r:id=\"" + strId + L"\" o:title=\"\" type=\"tile\"" + fopacity + L" />";
strNode = L"<v:fill " + strId + L" o:title=\"\" type=\"tile\"" + fopacity + L"/>";
else
strNode = L"<v:fill r:id=\"" + strId + L"\" o:title=\"\" type=\"frame\"" + fopacity + L" />";
strNode = L"<v:fill " + strId + L" o:title=\"\" type=\"frame\"" + fopacity + L"/>";
}
}
}
@ -183,7 +190,7 @@ namespace PPTX
}
*/
}
void CalculateLine(PPTX::Logic::SpPr& oSpPr, nullable<ShapeStyle>& pShapeStyle, NSCommon::smart_ptr<PPTX::Theme>& oTheme,
void CalculateLine(BYTE lDocType, PPTX::Logic::SpPr& oSpPr, nullable<ShapeStyle>& pShapeStyle, NSCommon::smart_ptr<PPTX::Theme>& oTheme,
NSCommon::smart_ptr<PPTX::Logic::ClrMap>& oClrMap, std::wstring& strAttr, std::wstring& strNode, bool bOle)
{
PPTX::Logic::Ln line;

View File

@ -43,10 +43,10 @@ namespace PPTX
{
namespace Logic
{
void CalculateFill(PPTX::Logic::SpPr& oSpPr, nullable<ShapeStyle>& pShapeStyle, smart_ptr<PPTX::Theme>& oTheme,
void CalculateFill(BYTE lDocType, PPTX::Logic::SpPr& oSpPr, nullable<ShapeStyle>& pShapeStyle, smart_ptr<PPTX::Theme>& oTheme,
smart_ptr<PPTX::Logic::ClrMap>& oClrMap, std::wstring& strAttr, std::wstring& strNode, bool bOle = false, bool bSignature = false);
void CalculateLine(PPTX::Logic::SpPr& oSpPr, nullable<ShapeStyle>& pShapeStyle,
void CalculateLine(BYTE lDocType, PPTX::Logic::SpPr& oSpPr, nullable<ShapeStyle>& pShapeStyle,
smart_ptr<PPTX::Theme>& oTheme, smart_ptr<PPTX::Logic::ClrMap>& oClrMap, std::wstring& strAttr, std::wstring& strNode, bool bOle = false);
class SpTreeElem : public WrapperWritingElement

View File

@ -232,7 +232,7 @@ namespace PPTX
pWriter->StartNode(m_name);
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("typeface"), typeface);
pWriter->WriteAttribute(_T("typeface"), XmlUtils::EncodeXmlString(typeface));
pWriter->WriteAttribute(_T("pitchFamily"), pitchFamily);
pWriter->WriteAttribute(_T("charset"), charset);
pWriter->WriteAttribute(_T("panose"), panose);

View File

@ -338,8 +338,7 @@ namespace PPTX
if (false == detectImageExtension.empty())
{
if (sImageExtension.empty())
sImageExtension = detectImageExtension;
sImageExtension = detectImageExtension;
//папки media может не быть в случае, когда все картинки base64(поскольку файл временный, папку media не создаем)
std::wstring tempFilePath = pReader->m_strFolder + FILE_SEPARATOR_STR;

View File

@ -14,7 +14,7 @@ public:
void SetImageValid(const std::wstring& file);
void SetImageInvalid(const std::wstring& file);
void Sign();
int Sign();
private:
COOXMLSigner_private* m_internal;

View File

@ -615,7 +615,7 @@ public:
return nSignNum;
}
void Sign()
int Sign()
{
Parse();
@ -650,6 +650,8 @@ public:
int nSignNum = AddSignatureReference();
NSFile::CFileBinary::SaveToFile(m_sFolder + L"/_xmlsignatures/sig" + std::to_wstring(nSignNum + 1) + L".xml", builderResult.GetData(), false);
return (sSignedXml.empty()) ? 1 : 0;
}
};
@ -678,7 +680,7 @@ void COOXMLSigner::SetImageInvalid(const std::wstring& file)
m_internal->SetImageInvalid(file);
}
void COOXMLSigner::Sign()
int COOXMLSigner::Sign()
{
m_internal->Sign();
return m_internal->Sign();
}

View File

@ -94,6 +94,7 @@ public:
m_pBase = NULL;
m_separator = ";;;;;;;ONLYOFFICE;;;;;;;";
m_alg = OOXML_HASH_ALG_INVALID;
}
virtual ~CCertificate_openssl_private()
{
@ -131,10 +132,22 @@ public:
return "";
}
if (asn1_serial->type == V_ASN1_NEG_INTEGER)
{
std::string sPositive = "1";
for (int i = 0; i < asn1_serial->length; ++i)
sPositive += "00";
BIGNUM* pn = NULL;
int res = BN_hex2bn(&pn, sPositive.c_str());
BN_add(bn, bn, pn);
BN_free(pn);
}
char *tmp = BN_bn2dec(bn);
std::string sReturn(tmp);
BN_free(bn);
OPENSSL_free(tmp);
return sReturn;
}
@ -271,7 +284,7 @@ public:
return GetNumber();
}
public:
public:
std::string Sign(const std::string& sXml)
{
EVP_MD_CTX* pCtx = EVP_MD_CTX_create();
@ -385,7 +398,7 @@ public:
bool Verify(const std::string& sXml, std::string& sXmlSignature, int nAlg)
{
EVP_MD_CTX* pCtx = EVP_MD_CTX_create();
const EVP_MD* pDigest = Get_EVP_MD(this->GetHashAlg());
const EVP_MD* pDigest = Get_EVP_MD(nAlg);
int n1 = EVP_VerifyInit(pCtx, pDigest);
n1 = n1;
@ -442,8 +455,36 @@ public:
if (!m_cert)
return algs;
// TODO:
// Check algs in cert
//const X509_ALGOR* pAlgr = X509_get0_tbs_sigalg(m_cert);
//int nAlg = OBJ_obj2nid(pAlgr);
int nAlg = X509_get_signature_nid(m_cert);
switch (nAlg)
{
case NID_sha1:
case NID_sha1WithRSA:
case NID_sha1WithRSAEncryption:
algs.push_back(OOXML_HASH_ALG_SHA1);
break;
case NID_sha256:
case NID_sha256WithRSAEncryption:
algs.push_back(OOXML_HASH_ALG_SHA256);
break;
case NID_sha224:
case NID_sha224WithRSAEncryption:
algs.push_back(OOXML_HASH_ALG_SHA224);
break;
case NID_sha384:
case NID_sha384WithRSAEncryption:
algs.push_back(OOXML_HASH_ALG_SHA384);
break;
case NID_sha512:
case NID_sha512WithRSAEncryption:
algs.push_back(OOXML_HASH_ALG_SHA512);
break;
default:
break;
}
if (algs.empty())
m_alg = OOXML_HASH_ALG_SHA1;

View File

@ -3518,11 +3518,15 @@ namespace NExtractTools
{
nRes = html_zip2docx_dir(sFrom, sDocxDir, sTemp, params);
}
else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_MHT == nFormatFrom)
else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_PACKAGE == nFormatFrom)
{
nRes = mht2docx_dir(sFrom, sDocxDir, sTemp, params);
nRes = package2docx_dir(sFrom, sDocxDir, sTemp, params);
}
else
else if (AVS_OFFICESTUDIO_FILE_DOCUMENT_MHT == nFormatFrom)
{
nRes = mht2docx_dir(sFrom, sDocxDir, sTemp, params);
}
else
nRes = AVS_FILEUTILS_ERROR_CONVERT_PARAMS;
if(SUCCEEDED_X2T(nRes))
{

View File

@ -6870,7 +6870,8 @@ int BinaryFileReader::ReadFile(const std::wstring& sSrcFileName, std::wstring sD
int nType = 0;
std::string version = "";
std::string dst_len = "";
while (true)
while (nIndex < nBase64DataSize)
{
nIndex++;
BYTE _c = pBase64Data[nIndex];