Preserve empty device content types with an explicit context flag

This commit is contained in:
evgeny committed 2026-11-03 12:39:46 +01:00
1 parent 4dc5e1b11c
commit a1dd1fda75
3 files changed
+14 -14

No files matched your search

+3 -3
View File
@@ -430,7 +430,7 @@ static int dm_build_body(struct dm_state* dm, const struct dm_conv* c, uint64_t
u_free(enc); return -1;
}
size_t body_len = DM_MSG_FIXED_HDR + ct_len + 2 + enc_len + (media ? DM_MEDIA_DESC_SIZE : 0) + DM_MSG_SIG_SIZE;
if (context_size) body_len += context_size + 1;
body_len += context_size;
uint8_t* body = u_malloc(body_len);
if (!body) { u_free(enc); return -1; }
size_t off = 0;
@@ -438,11 +438,11 @@ static int dm_build_body(struct dm_state* dm, const struct dm_conv* c, uint64_t
memcpy(body + off, &seq, 8); off += 8;
memcpy(body + off, &ts, 8); off += 8;
memcpy(body + off, &author, 8); off += 8;
if (context_size) { body[off++] = 0; memcpy(body + off, context, context_size); off += context_size; }
body[off++] = ct_len;
memcpy(body + off, ct, ct_len); off += ct_len;
uint16_t el = (uint16_t)enc_len;
uint16_t el = (uint16_t)(enc_len | (context_size ? DM_CONTEXT_FLAG : 0));
memcpy(body + off, &el, 2); off += 2;
if (context_size) { memcpy(body + off, context, context_size); off += context_size; }
memcpy(body + off, enc, enc_len); off += enc_len;
if (media) { memcpy(body + off, media, DM_MEDIA_DESC_SIZE); off += DM_MEDIA_DESC_SIZE; }
/* подпись по всем полям до sig */