diff --git a/src/cmdu.c b/src/cmdu.c index e85246110ebb5b19d63ae7fdf22cb22e7eedb654..007703397e4e337c74dead2f32b60a65cea9c2f6 100644 --- a/src/cmdu.c +++ b/src/cmdu.c @@ -475,9 +475,12 @@ int cmdu_put_tlv(struct cmdu_buff *c, struct tlv *t) int cmdu_put(struct cmdu_buff *c, uint8_t *bytes, int len) { - if (!c || !bytes) + if (!c) return -1; + if (!bytes) + return 0; + if (c->end - c->tail < len) { fprintf(stderr, "%s: %d: c->end = %p c->tail = %p\n", __func__, __LINE__, c->end, c->tail);