Bound avatar manifest sizes before numeric conversion
This commit is contained in:
1 parent
3e1cc8af85
commit
52f4628fe0
2 files changed
+12
-2
No files matched your search
@@ -12,6 +12,8 @@
|
||||
#include <QPainter>
|
||||
#include <QDialog>
|
||||
#include <QPushButton>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
extern "C" {
|
||||
#include "utun_instance.h"
|
||||
#include "chat/chat_core.h"
|
||||
@@ -77,6 +79,13 @@ private slots:
|
||||
QFile webp(directory.path() + '/' + prepared.record.preview); QVERIFY(webp.open(QIODevice::ReadOnly));
|
||||
const QByteArray encoded=webp.readAll(); QCOMPARE(encoded.left(4),QByteArray("RIFF")); QVERIFY(encoded.contains("VP8 "));
|
||||
QVERIFY(!AvatarCache::load(path, prepared.hash).image.isNull());
|
||||
QFile description(path); QVERIFY(description.open(QIODevice::ReadOnly));
|
||||
QJsonObject record=QJsonDocument::fromJson(description.readAll()).object(); description.close();
|
||||
record["original_bytes"]=1e99;
|
||||
const QByteArray oversized=QJsonDocument(record).toJson(QJsonDocument::Compact);
|
||||
const QString oversizedName=QCryptographicHash::hash(oversized,QCryptographicHash::Sha256).toHex()+".json";
|
||||
QString writeError; QVERIFY(AvatarCache::storeObject(directory.path(),oversizedName,oversized,writeError));
|
||||
QVERIFY(!AvatarCache::readObject(directory.path()+'/'+oversizedName,oversizedName).error.isEmpty());
|
||||
QVERIFY(AvatarCache::load(path, QString(64, '0')).image.isNull());
|
||||
QFile corrupt(path); QVERIFY(corrupt.open(QIODevice::Append)); QCOMPARE(corrupt.write("x"), 1LL); corrupt.close();
|
||||
QVERIFY(AvatarCache::load(path, prepared.hash).image.isNull());
|
||||
|
||||
Reference in new issue
Block a user