commit d620008fecd52c39c3eb5296bd3ba8025a0ab11c
parent 56486cec409e44d26b74a7f6716196a717abd189
Author: Jacob R. Edwards <n/a>
Date: Sat, 8 Oct 2022 15:09:07 -0700
Fix client error buffer termination
The memmove removing 'error: ' didn't copy the trailing nul, while
I could have had it copy one more byte, explicitly assigning nul
is more clear.
Diffstat:
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/lib/ap/client.c b/lib/ap/client.c
@@ -114,10 +114,11 @@ apc_read(struct apc *apc)
apc->response->len -= len + 1);
if (strcmp(buf, "ok") == 0 || strncmp(buf, "error: ", 7) == 0) {
- if (*buf == 'e')
+ if (*buf == 'e') {
memmove(buf, buf + 7, len - 7);
- if (apc->status)
- free(apc->status);
+ buf[len - 7] = 0;
+ }
+ free(apc->status);
apc->status = buf;
return NULL;
}