Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KItinerary
Commits
af8731a5
Commit
af8731a5
authored
Aug 06, 2022
by
Volker Krause
Browse files
Workaround for UIC 918.3 version 1 tickets claiming to use version 2 format
Found in PKP samples.
parent
fd40d9ca
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lib/uic9183/uic9183header.cpp
View file @
af8731a5
...
...
@@ -19,6 +19,12 @@ enum {
ZlibHeaderSize
=
2
};
static
bool
isZlibHeader
(
const
QByteArray
&
data
,
int
offset
)
{
// check for zlib headers 0x789C or 0x78DA
return
((
uint8_t
)
data
[
offset
]
==
0x78
&&
((
uint8_t
)
data
[
offset
+
1
]
==
0x9C
||
(
uint8_t
)
data
[
offset
+
1
]
==
0xDA
));
}
Uic9183Header
::
Uic9183Header
()
=
default
;
Uic9183Header
::
Uic9183Header
(
const
QByteArray
&
data
)
{
...
...
@@ -33,14 +39,17 @@ Uic9183Header::Uic9183Header(const QByteArray& data)
if
(
version
!=
1
&&
version
!=
2
)
{
return
;
}
const
auto
offset
=
PrefixSize
+
(
version
==
1
?
SignatureSizeV1
:
SignatureSizeV2
)
+
SuffixSize
;
auto
offset
=
PrefixSize
+
(
version
==
1
?
SignatureSizeV1
:
SignatureSizeV2
)
+
SuffixSize
;
if
(
data
.
size
()
<
offset
+
ZlibHeaderSize
)
{
return
;
}
// check for zlib headers 0x789C or 0x78DA
if
((
uint8_t
)
data
[
offset
]
!=
0x78
||
((
uint8_t
)
data
[
offset
+
1
]
!=
0x9C
&&
(
uint8_t
)
data
[
offset
+
1
]
!=
0xDA
))
{
// compressedMessageOffset() contains workarounds for wrong version claims, which the above check doesn't do yet
m_data
=
data
;
offset
=
compressedMessageOffset
();
if
(
!
isZlibHeader
(
data
,
offset
))
{
qCWarning
(
Log
)
<<
"UIC 918-3 payload has wrong zlib header."
;
m_data
.
clear
();
return
;
}
...
...
@@ -56,7 +65,17 @@ int Uic9183Header::signatureSize() const
{
switch
(
version
())
{
case
1
:
return
SignatureSizeV1
;
case
2
:
return
SignatureSizeV2
;
case
2
:
{
// workaround some tickets claiming version 2 but actually being version 1...
if
(
isZlibHeader
(
m_data
,
PrefixSize
+
SignatureSizeV2
+
SuffixSize
))
{
return
SignatureSizeV2
;
}
if
(
isZlibHeader
(
m_data
,
PrefixSize
+
SignatureSizeV1
+
SuffixSize
))
{
return
SignatureSizeV1
;
}
return
SignatureSizeV2
;
}
};
return
0
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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