Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
4d1cb2dc
Kaydet (Commit)
4d1cb2dc
authored
Eki 20, 2014
tarafından
Matúš Kukan
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
package: Zipping STORED entry is the same as rawWrite and we don't encrypt it
Change-Id: Ie3f8ac261a70c9a2b5182fc7d36938d0a46ec045
üst
2d92a84a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
71 deletions
+58
-71
ZipOutputEntry.cxx
package/source/zipapi/ZipOutputEntry.cxx
+36
-58
ZipPackage.cxx
package/source/zippackage/ZipPackage.cxx
+1
-3
ZipPackageStream.cxx
package/source/zippackage/ZipPackageStream.cxx
+21
-10
No files found.
package/source/zipapi/ZipOutputEntry.cxx
Dosyayı görüntüle @
4d1cb2dc
...
...
@@ -51,6 +51,7 @@ ZipOutputEntry::ZipOutputEntry( const uno::Reference< uno::XComponentContext >&
,
m_bEncryptCurrentEntry
(
bEncrypt
)
,
m_pCurrentStream
(
NULL
)
{
assert
(
m_pCurrentEntry
->
nMethod
==
DEFLATED
&&
"Use ZipPackageStream::rawWrite() for STORED entries"
);
if
(
m_bEncryptCurrentEntry
)
{
m_xCipherContext
=
ZipFile
::
StaticGetCipher
(
rxContext
,
pStream
->
GetEncryptionData
(),
true
);
...
...
@@ -69,49 +70,37 @@ void SAL_CALL ZipOutputEntry::closeEntry( )
ZipEntry
*
pEntry
=
m_pCurrentEntry
;
if
(
pEntry
)
{
switch
(
pEntry
->
nMethod
)
m_aDeflater
.
finish
();
while
(
!
m_aDeflater
.
finished
())
doDeflate
();
if
((
pEntry
->
nFlag
&
8
)
==
0
)
{
case
DEFLATED
:
m_aDeflater
.
finish
();
while
(
!
m_aDeflater
.
finished
())
doDeflate
();
if
((
pEntry
->
nFlag
&
8
)
==
0
)
{
if
(
pEntry
->
nSize
!=
m_aDeflater
.
getTotalIn
())
{
OSL_FAIL
(
"Invalid entry size"
);
}
if
(
pEntry
->
nCompressedSize
!=
m_aDeflater
.
getTotalOut
())
{
// Different compression strategies make the merit of this
// test somewhat dubious
pEntry
->
nCompressedSize
=
m_aDeflater
.
getTotalOut
();
}
if
(
pEntry
->
nCrc
!=
m_aCRC
.
getValue
())
{
OSL_FAIL
(
"Invalid entry CRC-32"
);
}
}
else
{
if
(
!
m_bEncryptCurrentEntry
)
{
pEntry
->
nSize
=
m_aDeflater
.
getTotalIn
();
pEntry
->
nCompressedSize
=
m_aDeflater
.
getTotalOut
();
}
pEntry
->
nCrc
=
m_aCRC
.
getValue
();
}
m_aDeflater
.
reset
();
m_aCRC
.
reset
();
break
;
case
STORED
:
if
(
!
((
pEntry
->
nFlag
&
8
)
==
0
))
OSL_FAIL
(
"Serious error, one of compressed size, size or CRC was -1 in a STORED stream"
);
break
;
default
:
OSL_FAIL
(
"Invalid compression method"
);
break
;
if
(
pEntry
->
nSize
!=
m_aDeflater
.
getTotalIn
())
{
OSL_FAIL
(
"Invalid entry size"
);
}
if
(
pEntry
->
nCompressedSize
!=
m_aDeflater
.
getTotalOut
())
{
// Different compression strategies make the merit of this
// test somewhat dubious
pEntry
->
nCompressedSize
=
m_aDeflater
.
getTotalOut
();
}
if
(
pEntry
->
nCrc
!=
m_aCRC
.
getValue
())
{
OSL_FAIL
(
"Invalid entry CRC-32"
);
}
}
else
{
if
(
!
m_bEncryptCurrentEntry
)
{
pEntry
->
nSize
=
m_aDeflater
.
getTotalIn
();
pEntry
->
nCompressedSize
=
m_aDeflater
.
getTotalOut
();
}
pEntry
->
nCrc
=
m_aCRC
.
getValue
();
}
m_aDeflater
.
reset
();
m_aCRC
.
reset
();
if
(
m_bEncryptCurrentEntry
)
{
...
...
@@ -137,24 +126,13 @@ void SAL_CALL ZipOutputEntry::closeEntry( )
void
SAL_CALL
ZipOutputEntry
::
write
(
const
Sequence
<
sal_Int8
>&
rBuffer
,
sal_Int32
nNewOffset
,
sal_Int32
nNewLength
)
throw
(
IOException
,
RuntimeException
)
{
switch
(
m_pCurrentEntry
->
nMethod
)
if
(
!
m_aDeflater
.
finished
()
)
{
case
DEFLATED
:
if
(
!
m_aDeflater
.
finished
())
{
m_aDeflater
.
setInputSegment
(
rBuffer
,
nNewOffset
,
nNewLength
);
while
(
!
m_aDeflater
.
needsInput
())
doDeflate
();
if
(
!
m_bEncryptCurrentEntry
)
m_aCRC
.
updateSegment
(
rBuffer
,
nNewOffset
,
nNewLength
);
}
break
;
case
STORED
:
{
Sequence
<
sal_Int8
>
aTmpBuffer
(
rBuffer
.
getConstArray
(),
nNewLength
);
m_pZipOutputStream
->
getChucker
().
WriteBytes
(
aTmpBuffer
);
}
break
;
m_aDeflater
.
setInputSegment
(
rBuffer
,
nNewOffset
,
nNewLength
);
while
(
!
m_aDeflater
.
needsInput
())
doDeflate
();
if
(
!
m_bEncryptCurrentEntry
)
m_aCRC
.
updateSegment
(
rBuffer
,
nNewOffset
,
nNewLength
);
}
}
...
...
package/source/zippackage/ZipPackage.cxx
Dosyayı görüntüle @
4d1cb2dc
...
...
@@ -998,9 +998,7 @@ void ZipPackage::WriteMimetypeMagicFile( ZipOutputStream& aZipOut )
try
{
aZipOut
.
putNextEntry
(
*
pEntry
);
ZipOutputEntry
aZipEntry
(
m_xContext
,
&
aZipOut
,
*
pEntry
,
NULL
);
aZipEntry
.
write
(
aType
,
0
,
nBufferLength
);
aZipEntry
.
closeEntry
();
aZipOut
.
rawWrite
(
aType
,
0
,
nBufferLength
);
aZipOut
.
rawCloseEntry
();
}
catch
(
const
::
com
::
sun
::
star
::
io
::
IOException
&
r
)
...
...
package/source/zippackage/ZipPackageStream.cxx
Dosyayı görüntüle @
4d1cb2dc
...
...
@@ -485,8 +485,8 @@ bool ZipPackageStream::saveChild(
pTempEntry
->
sPath
=
rPath
;
pTempEntry
->
nPathLen
=
(
sal_Int16
)(
OUStringToOString
(
pTempEntry
->
sPath
,
RTL_TEXTENCODING_UTF8
).
getLength
()
);
bool
bToBeEncrypted
=
m_bToBeEncrypted
&&
(
rEncryptionKey
.
getLength
()
||
m_bHaveOwnKey
);
bool
bToBeCompressed
=
bToBeEncrypted
?
sal_True
:
m_bToBeCompressed
;
const
bool
bToBeEncrypted
=
m_bToBeEncrypted
&&
(
rEncryptionKey
.
getLength
()
||
m_bHaveOwnKey
);
const
bool
bToBeCompressed
=
bToBeEncrypted
?
sal_True
:
m_bToBeCompressed
;
aPropSet
[
PKG_MNFST_MEDIATYPE
].
Name
=
sMediaTypeProperty
;
aPropSet
[
PKG_MNFST_MEDIATYPE
].
Value
<<=
GetMediaType
(
);
...
...
@@ -732,20 +732,31 @@ bool ZipPackageStream::saveChild(
try
{
rZipOut
.
putNextEntry
(
*
pTempEntry
,
bToBeEncrypted
);
ZipOutputEntry
aZipEntry
(
m_xContext
,
&
rZipOut
,
*
pTempEntry
,
this
,
bToBeEncrypted
);
// the entry is provided to the ZipOutputStream that will delete it
pAutoTempEntry
.
release
();
sal_Int32
nLength
;
uno
::
Sequence
<
sal_Int8
>
aSeq
(
n_ConstBufferSize
);
do
if
(
pTempEntry
->
nMethod
==
STORED
)
{
nLength
=
xStream
->
readBytes
(
aSeq
,
n_ConstBufferSize
);
aZipEntry
.
write
(
aSeq
,
0
,
nLength
);
do
{
nLength
=
xStream
->
readBytes
(
aSeq
,
n_ConstBufferSize
);
rZipOut
.
rawWrite
(
aSeq
,
0
,
nLength
);
}
while
(
nLength
==
n_ConstBufferSize
);
}
else
{
ZipOutputEntry
aZipEntry
(
m_xContext
,
&
rZipOut
,
*
pTempEntry
,
this
,
bToBeEncrypted
);
do
{
nLength
=
xStream
->
readBytes
(
aSeq
,
n_ConstBufferSize
);
aZipEntry
.
write
(
aSeq
,
0
,
nLength
);
}
while
(
nLength
==
n_ConstBufferSize
);
aZipEntry
.
closeEntry
();
}
while
(
nLength
==
n_ConstBufferSize
);
aZipEntry
.
closeEntry
();
rZipOut
.
rawCloseEntry
();
}
catch
(
ZipException
&
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment