+bool
+blob_check_type(const void *ptr, int len, int type)
+{
+ const char *data = ptr;
+
+ if (type >= BLOB_ATTR_LAST)
+ return false;
+
+ if (type >= BLOB_ATTR_INT8 && type <= BLOB_ATTR_INT64) {
+ if (len != blob_type_minlen[type])
+ return false;
+ } else {
+ if (len < blob_type_minlen[type])
+ return false;
+ }
+
+ if (type == BLOB_ATTR_STRING && data[len - 1] != 0)
+ return false;
+
+ return true;
+}
+