Don't crash on decoding unsupported-attributes
This commit is contained in:
parent
1b1079b679
commit
28bb06d18e
2 changed files with 7 additions and 3 deletions
|
@ -38,7 +38,7 @@ IppMsg::IppMsg(QNetworkReply* resp)
|
||||||
|
|
||||||
while(!bts.atEnd())
|
while(!bts.atEnd())
|
||||||
{
|
{
|
||||||
if(bts.peekU8() <= IppTag::PrinterAttrs) {
|
if(bts.peekU8() <= IppTag::UnsupportedAttrs) {
|
||||||
|
|
||||||
if(currentAttrType == IppTag::OpAttrs) {
|
if(currentAttrType == IppTag::OpAttrs) {
|
||||||
_opAttrs = attrs;
|
_opAttrs = attrs;
|
||||||
|
@ -49,6 +49,9 @@ IppMsg::IppMsg(QNetworkReply* resp)
|
||||||
else if (currentAttrType == IppTag::PrinterAttrs) {
|
else if (currentAttrType == IppTag::PrinterAttrs) {
|
||||||
_printerAttrs = attrs;
|
_printerAttrs = attrs;
|
||||||
}
|
}
|
||||||
|
else if (currentAttrType == IppTag::UnsupportedAttrs) {
|
||||||
|
qDebug() << "WARNING: unsupported attrs reported:" << attrs;
|
||||||
|
}
|
||||||
|
|
||||||
if(bts >>= (uint8_t)IppTag::EndAttrs) {
|
if(bts >>= (uint8_t)IppTag::EndAttrs) {
|
||||||
break;
|
break;
|
||||||
|
@ -78,12 +81,12 @@ QString IppMsg::consume_attribute(QJsonObject& attrs, Bytestream& data, QString
|
||||||
data/tmp_len >> tmp_str;
|
data/tmp_len >> tmp_str;
|
||||||
name = tmp_str!="" ? tmp_str.c_str() : lastName;
|
name = tmp_str!="" ? tmp_str.c_str() : lastName;
|
||||||
|
|
||||||
|
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case OpAttrs:
|
case OpAttrs:
|
||||||
case JobAttrs:
|
case JobAttrs:
|
||||||
case EndAttrs:
|
case EndAttrs:
|
||||||
case PrinterAttrs:
|
case PrinterAttrs:
|
||||||
|
case UnsupportedAttrs:
|
||||||
Q_ASSERT(false);
|
Q_ASSERT(false);
|
||||||
case Integer:
|
case Integer:
|
||||||
case Enum:
|
case Enum:
|
||||||
|
@ -245,7 +248,6 @@ Bytestream IppMsg::encode_attr(quint8 tag, QString name, QJsonValueRef value)
|
||||||
}
|
}
|
||||||
case Resolution:
|
case Resolution:
|
||||||
{
|
{
|
||||||
qDebug() << value << value.toObject();
|
|
||||||
qint32 x = value.toObject()["x"].toInt();
|
qint32 x = value.toObject()["x"].toInt();
|
||||||
qint32 y = value.toObject()["y"].toInt();
|
qint32 y = value.toObject()["y"].toInt();
|
||||||
qint8 units = value.toObject()["units"].toInt();
|
qint8 units = value.toObject()["units"].toInt();
|
||||||
|
|
|
@ -19,6 +19,8 @@ public:
|
||||||
JobAttrs = 0x02,
|
JobAttrs = 0x02,
|
||||||
EndAttrs = 0x03,
|
EndAttrs = 0x03,
|
||||||
PrinterAttrs = 0x04,
|
PrinterAttrs = 0x04,
|
||||||
|
UnsupportedAttrs = 0x05,
|
||||||
|
Unsupported = 0x10,
|
||||||
Integer = 0x21,
|
Integer = 0x21,
|
||||||
Boolean = 0x22,
|
Boolean = 0x22,
|
||||||
Enum = 0x23,
|
Enum = 0x23,
|
||||||
|
|
Loading…
Reference in a new issue