if (type == FR_TYPE_NULL) {
type = cbor_guess_type(&work_dbuff, false);
- if (type < 0) {
- fr_strerror_printf("Invalid cbor - insufficient data");
- return type;
- }
- if (type == FR_TYPE_NULL) {
- fr_strerror_printf("Invalid cbor - unable to determine data type");
- return 0;
- }
+ if (type == FR_TYPE_NULL) return 0;
}
fr_value_box_init(vb, type, enumv, tainted);
/*
* get the next byte, which is a CBOR header.
*/
- FR_DBUFF_OUT_RETURN(&major, &work_dbuff);
+ slen = fr_dbuff_out(&major, &work_dbuff);
+ if (slen <= 0) {
+ no_data:
+ fr_strerror_const("Invalid cbor - insufficient data");
+ return FR_TYPE_NULL;
+ }
info = major & 0x1f;
major >>= 5;
return FR_TYPE_ETHERNET;
case 52:
- FR_DBUFF_OUT_RETURN(&major, &work_dbuff);
+ slen = fr_dbuff_out(&major, &work_dbuff);
+ if (slen <= 0) goto no_data;
major >>= 5;
* converted to data type 'octets'. This work involves mostly parsing the cbor data, which isn't
* trivial.
*/
+ fr_strerror_const("Invalid cbor - unable to determine data type");
return FR_TYPE_NULL;
}
fr_type_t type;
type = cbor_guess_type(&work_dbuff, true);
- if (type == FR_TYPE_NULL) {
- fr_strerror_printf("Invalid cbor - unable to determine data type");
- return -fr_dbuff_used(&work_dbuff);
- }
+ if (type == FR_TYPE_NULL) return -fr_dbuff_used(&work_dbuff);
/*
* @todo - the value here isn't a cbor octets type, but is instead cbor data. Since cbor