Commit 38d1b030 authored by Lucas Russo's avatar Lucas Russo

hal/sm_io/modules/acq/*: add channel limit checking

This finishes the quick fix for github issue #21.
parent 45a271f6
......@@ -30,6 +30,7 @@
#define ACQ_NUM_SAMPLES_OOR 1 /* Number of samples out of range */
#define ACQ_NOT_COMPLETED 2 /* Acquisition not completed */
#define ACQ_BLOCK_OOR 3 /* Block number out of range */
#define ACQ_REPLY_END 4 /* End marker */
#define ACQ_NUM_CHAN_OOR 4 /* Channel number out of range */
#define ACQ_REPLY_END 5 /* End marker */
#endif
......@@ -107,7 +107,7 @@ static void *_acq_data_acquire (void *owner, void *args)
uint32_t chan = *(uint32_t *) zframe_data (zmsg_pop (*exp_msg->msg));
/* number of samples required is out of the maximum limit */
if (num_samples >= SMIO_ACQ_HANDLER(self)->acq_buf[chan].max_samples) {
if (num_samples > SMIO_ACQ_HANDLER(self)->acq_buf[chan].max_samples-1) {
DBE_DEBUG (DBG_SM_IO | DBG_LVL_WARN, "[sm_io:acq] data_acquire: "
"Number of samples required is out of the maximum limit\n");
......@@ -118,6 +118,18 @@ static void *_acq_data_acquire (void *owner, void *args)
goto err_smp_exceeded;
}
/* channel required is out of the limit */
if (chan > SMIO_ACQ_NUM_CHANNELS-1) {
DBE_DEBUG (DBG_SM_IO | DBG_LVL_WARN, "[sm_io:acq] data_acquire: "
"Channel required is out of the maximum limit\n");
/* Message is:
* frame 0: error code */
_send_client_response (ACQ_NUM_CHAN_OOR, 0, NULL, false,
self->worker, exp_msg->reply_to);
goto err_smp_exceeded;
}
DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:acq] data_acquire: "
"Current acq params: number of samples = %u, channel = %u\n",
num_samples, chan);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment