From f163912b5d577705c3d42428b0af75222f84b761 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 26 Dec 2016 13:42:30 +0100 Subject: QMimeMagicRule: endianness fixes * apply endianness to the mask as well * do not apply endianness to "host" entries, they were wrongly behaving exactly like "big endian" entries. The issue with the mask was detected by the audio/aac magic which failed to identify the test file ct_faac-adts.aac since it was applying the mask 0xFFF6 instead of 0xF6FF (on a little-endian machine). Not yet detected by tst_qmimedatabase which is based on shared-mime-info 1.0, will be covered by the upgrade to 1.8 in dev. Change-Id: I4fb7af2d367099817e712b14f2a031066d0ac432 Reviewed-by: Thiago Macieira --- src/corelib/mimetypes/qmimemagicrule.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/corelib/mimetypes/qmimemagicrule.cpp b/src/corelib/mimetypes/qmimemagicrule.cpp index 7a807dccdb..5bbf1bba9d 100644 --- a/src/corelib/mimetypes/qmimemagicrule.cpp +++ b/src/corelib/mimetypes/qmimemagicrule.cpp @@ -299,20 +299,30 @@ QMimeMagicRule::QMimeMagicRule(const QString &type, } break; case Big16: - case Host16: case Little16: if (m_number <= quint16(-1)) { m_number = m_type == Little16 ? qFromLittleEndian(m_number) : qFromBigEndian(m_number); + if (m_numberMask != 0) + m_numberMask = m_type == Little16 ? qFromLittleEndian(m_numberMask) : qFromBigEndian(m_numberMask); + } + Q_FALLTHROUGH(); + case Host16: + if (m_number <= quint16(-1)) { if (m_numberMask == 0) m_numberMask = quint16(-1); m_matchFunction = &QMimeMagicRule::matchNumber; } break; case Big32: - case Host32: case Little32: if (m_number <= quint32(-1)) { m_number = m_type == Little32 ? qFromLittleEndian(m_number) : qFromBigEndian(m_number); + if (m_numberMask != 0) + m_numberMask = m_type == Little32 ? qFromLittleEndian(m_numberMask) : qFromBigEndian(m_numberMask); + } + Q_FALLTHROUGH(); + case Host32: + if (m_number <= quint32(-1)) { if (m_numberMask == 0) m_numberMask = quint32(-1); m_matchFunction = &QMimeMagicRule::matchNumber; -- cgit v1.2.3