Introduction
Introduction Statistics Contact Development Disclaimer Help
Check that non-binary types end with ".\r\n" - sacc - sacc(omys), simple consol…
git clone git://bitreich.org/sacc/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65…
Log
Files
Refs
Tags
LICENSE
---
commit 34fd4f17068b408353bb6ae1df3eb4a58c259e25
parent cd386e712b7587740115c0fb0815a43052758ae2
Author: Quentin Rameau <[email protected]>
Date: Sat, 30 Jan 2021 19:44:16 +0100
Check that non-binary types end with ".\r\n"
Otherwise that means that the remote end send incomplete data.
Thanks to jhumphrey for spotting that!
Diffstat:
M sacc.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/sacc.c b/sacc.c
@@ -599,20 +599,25 @@ cleanup:
static int
fetchitem(Item *item)
{
+ char *raw, *r;
int sock;
if ((sock = connectto(item->host, item->port)) < 0 ||
sendselector(sock, item->selector) < 0)
return 0;
- item->raw = getrawitem(sock);
+ raw = getrawitem(sock);
close(sock);
- if (item->raw && !*item->raw) {
+ if (raw == NULL || !*raw) {
diag("Empty response from server");
- clear(&item->raw);
+ clear(&raw);
+ } else if ((r = strrchr(raw, '.')) == NULL || strcmp(r, ".\r\n")) {
+ diag("Incomplete response from server");
+ } else {
+ *r = '\0';
}
- return (item->raw != NULL);
+ return ((item->raw = raw) != NULL);
}
static void
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.