- /*
- * Setup lttng message with payload size set to the event list size in
- * bytes and then copy list into the llm payload.
- */
- ret = setup_lttng_msg_no_cmd_header(cmd_ctx, fields,
- sizeof(struct lttng_event_field) * nb_fields);
- free(fields);
+ if (nb_fields > UINT32_MAX) {
+ ret = LTTNG_ERR_OVERFLOW;
+ goto error;
+ }
+
+ cmd_header.count = nb_fields;
+
+ ret = setup_lttng_msg(cmd_ctx, payload.data, payload.size,
+ &cmd_header, sizeof(cmd_header));