Don't crash on decoding unsupported-attributes

This commit is contained in:
Anton Thomasson 2020-06-03 20:42:46 +02:00
parent 1b1079b679
commit 28bb06d18e
2 changed files with 7 additions and 3 deletions

View file

@ -38,7 +38,7 @@ IppMsg::IppMsg(QNetworkReply* resp)
while(!bts.atEnd())
{
if(bts.peekU8() <= IppTag::PrinterAttrs) {
if(bts.peekU8() <= IppTag::UnsupportedAttrs) {
if(currentAttrType == IppTag::OpAttrs) {
_opAttrs = attrs;
@ -49,6 +49,9 @@ IppMsg::IppMsg(QNetworkReply* resp)
else if (currentAttrType == IppTag::PrinterAttrs) {
_printerAttrs = attrs;
}
else if (currentAttrType == IppTag::UnsupportedAttrs) {
qDebug() << "WARNING: unsupported attrs reported:" << attrs;
}
if(bts >>= (uint8_t)IppTag::EndAttrs) {
break;
@ -78,12 +81,12 @@ QString IppMsg::consume_attribute(QJsonObject& attrs, Bytestream& data, QString
data/tmp_len >> tmp_str;
name = tmp_str!="" ? tmp_str.c_str() : lastName;
switch (tag) {
case OpAttrs:
case JobAttrs:
case EndAttrs:
case PrinterAttrs:
case UnsupportedAttrs:
Q_ASSERT(false);
case Integer:
case Enum:
@ -245,7 +248,6 @@ Bytestream IppMsg::encode_attr(quint8 tag, QString name, QJsonValueRef value)
}
case Resolution:
{
qDebug() << value << value.toObject();
qint32 x = value.toObject()["x"].toInt();
qint32 y = value.toObject()["y"].toInt();
qint8 units = value.toObject()["units"].toInt();

View file

@ -19,6 +19,8 @@ public:
JobAttrs = 0x02,
EndAttrs = 0x03,
PrinterAttrs = 0x04,
UnsupportedAttrs = 0x05,
Unsupported = 0x10,
Integer = 0x21,
Boolean = 0x22,
Enum = 0x23,