aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2020-06-19 13:30:06 +0200
committerMattias Andrée <maandree@kth.se>2020-06-19 13:30:06 +0200
commitac380e90626f1f007cdf7e17b87e50343eaf66ff (patch)
tree7c608be94abb9494c9482e438afa47674863ff41
parentAdd const to request structs (diff)
downloadlibaxl-ac380e90626f1f007cdf7e17b87e50343eaf66ff.tar.gz
libaxl-ac380e90626f1f007cdf7e17b87e50343eaf66ff.tar.bz2
libaxl-ac380e90626f1f007cdf7e17b87e50343eaf66ff.tar.xz
Fix error in libaxl_receive
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r--libaxl_receive.c9
-rw-r--r--libaxl_send_request.c6
2 files changed, 7 insertions, 8 deletions
diff --git a/libaxl_receive.c b/libaxl_receive.c
index 11ca644..e35cf1b 100644
--- a/libaxl_receive.c
+++ b/libaxl_receive.c
@@ -393,7 +393,6 @@ libaxl_receive(LIBAXL_CONTEXT *restrict ctx, union libaxl_input *restrict msgp,
case '?':
/* We know it is LIBAXL_REPLY message */
goto received_reply;
- break;
default:
abort();
@@ -463,7 +462,7 @@ received_reply:
break;
case '2':
- if (i + 2 <= n) {
+ if (i + 2 >= n) {
liberror_save_backtrace(NULL);
goto short_msg;
}
@@ -473,7 +472,7 @@ received_reply:
break;
case '4':
- if (i + 4 <= n) {
+ if (i + 4 >= n) {
liberror_save_backtrace(NULL);
goto short_msg;
}
@@ -490,7 +489,7 @@ received_reply:
break;
case 's':
- if (i + 2 <= n) {
+ if (i + 2 >= n) {
liberror_save_backtrace(NULL);
goto short_msg;
}
@@ -501,7 +500,7 @@ received_reply:
break;
case 'S':
- if (i + 4 <= n) {
+ if (i + 4 >= n) {
liberror_save_backtrace(NULL);
goto short_msg;
}
diff --git a/libaxl_send_request.c b/libaxl_send_request.c
index 11352c8..7172cdf 100644
--- a/libaxl_send_request.c
+++ b/libaxl_send_request.c
@@ -150,9 +150,9 @@ static const char *const req_formats[] = {
};
static int
-send_all(int fd, void *restrict data, size_t n, int flags, size_t *restrict progressp)
+send_all(int fd, const void *restrict data, size_t n, int flags, size_t *restrict progressp)
{
- char *bs = data;
+ const char *bs = data;
ssize_t r;
while (n) {
@@ -506,8 +506,8 @@ done:
return LIBAXL_ERROR_SYSTEM;
ctx->out_buf = buf = new;
ctx->out_buf_size = o;
- memset(&buf[n], 0, o - n);
}
+ memset(&buf[n], 0, o - n);
}
n = o / 4;
if (n > UINT16_MAX) {