Fix handling of invalid items in yankitem and delve - sacc - sacc(omys), simple console gopher client
HTML git clone git://bitreich.org/sacc/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/sacc/
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR LICENSE
---
DIR commit cc6a6881e06ab4b851c7778842374b953e51539c
DIR parent d16bb53db353da7b817b18809adf57b57c4f973e
HTML Author: Julian Schweinsberg <pazz0@0xfa.de>
Date: Sun, 27 Oct 2024 15:50:08 +0100
Fix handling of invalid items in yankitem and delve
An invalid item contains zeroes in all fields other than username.
That lead to an segmentation fault in itemuri. Additionally NULL strings
would have been printed in delve.
Error was observed on gopher://gopher.someodd.zip/1/phorum ( "mirror" of
erroneous content hosted at
gopher://gopher.0xfa.de/1/pazz0/p/someodd_phorum ).
Diffstat:
M sacc.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
---
DIR diff --git a/sacc.c b/sacc.c
@@ -798,6 +798,9 @@ cleanup:
void
yankitem(Item *item)
{
+ if (item->type == 0)
+ return;
+
itemuri(item, intbuf, sizeof(intbuf));
pipeuri(yanker, "Yanked", intbuf);
}
@@ -969,8 +972,7 @@ delve(Item *hole)
entry = hole;
break;
case 0:
- diag("Couldn't get %s:%s/%c%s", hole->host,
- hole->port, hole->type, hole->selector);
+ diag("Couldn't get %s", hole->username);
break;
case '4':
case '5':