summaryrefslogtreecommitdiff
path: root/src/plugins/serial
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/serial')
-rw-r--r--src/plugins/serial/serial_basic.c8
-rw-r--r--src/plugins/serial/serial_terminal.c11
2 files changed, 12 insertions, 7 deletions
diff --git a/src/plugins/serial/serial_basic.c b/src/plugins/serial/serial_basic.c
index e3322c1..21a239a 100644
--- a/src/plugins/serial/serial_basic.c
+++ b/src/plugins/serial/serial_basic.c
@@ -33,7 +33,9 @@
/* Serial Interface, Basic Mode plugin. */
+#if defined HAVE_ALLOCA_H
#include <alloca.h>
+#endif
#include <stdio.h>
#include <fcntl.h>
#include <time.h>
@@ -79,7 +81,7 @@ struct ipmb_msg_hdr {
unsigned char rqSA;
unsigned char rqSeq; /* RQ SEQ | RQ LUN */
unsigned char cmd;
- unsigned char data[0];
+ unsigned char data[];
};
/*
@@ -101,7 +103,7 @@ struct ipmi_get_message_rp {
unsigned char rsSA;
unsigned char rqSeq;
unsigned char cmd;
- unsigned char data[0];
+ unsigned char data[];
};
/*
@@ -128,7 +130,7 @@ struct serial_bm_parse_ctx{
* Receiving context
*/
struct serial_bm_recv_ctx {
- char buffer[SERIAL_BM_MAX_BUFFER_SIZE];
+ uint8_t buffer[SERIAL_BM_MAX_BUFFER_SIZE];
size_t buffer_size;
size_t max_buffer_size;
};
diff --git a/src/plugins/serial/serial_terminal.c b/src/plugins/serial/serial_terminal.c
index cd33422..4459f64 100644
--- a/src/plugins/serial/serial_terminal.c
+++ b/src/plugins/serial/serial_terminal.c
@@ -33,7 +33,9 @@
/* Serial Interface, Terminal Mode plugin. */
+#if defined HAVE_ALLOCA_H
#include <alloca.h>
+#endif
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
@@ -77,7 +79,7 @@ struct ipmb_msg_hdr {
unsigned char rqSA;
unsigned char rqSeq; /* RQ SEQ | RQ LUN */
unsigned char cmd;
- unsigned char data[0];
+ unsigned char data[];
};
/*
@@ -99,7 +101,7 @@ struct ipmi_get_message_rp {
unsigned char rsSA;
unsigned char rqSeq;
unsigned char cmd;
- unsigned char data[0];
+ unsigned char data[];
};
/*
@@ -371,8 +373,9 @@ recv_response(struct ipmi_intf * intf, unsigned char *data, int len)
}
p += rv;
resp_len += rv;
- if (*(p - 2) == ']' && (*(p - 1) == '\n' || *(p - 1) == '\r')) {
- *p = 0;
+ if (resp_len >= 2 && *(p - 2) == ']'
+ && (*(p - 1) == '\n' || *(p - 1) == '\r')) {
+ *(p - 1) = 0; /* overwrite EOL */
break;
}
}