From 00713a840ea1f4a2b1b2d9a885ef8f12e0a9e936 Mon Sep 17 00:00:00 2001 From: "psyc://psyced.org/~lynX" <@> Date: Mon, 28 Dec 2009 04:19:44 +0100 Subject: [PATCH] a possible way to croak() in spyc --- CHANGESTODO | 9 ++++++++ world/net/spyc/circuit.c | 9 +++++--- world/net/spyc/parse.c | 50 +++++++++++++++++++++------------------- 3 files changed, 41 insertions(+), 27 deletions(-) diff --git a/CHANGESTODO b/CHANGESTODO index e1c676d..9b2d728 100644 --- a/CHANGESTODO +++ b/CHANGESTODO @@ -4,6 +4,12 @@ vim:nosmarttab:syntax=diff | Essentially: whenever you fix something, move that line to the end of file. | - marks bugs & fixes, + marks new features, ? marks issues, * marks big stuff ________________________________________________________________________ +== SERIOUS!!! ========================================================== +¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ +- large submissions into scratchpad can crash the driver + +- configure script fails on libidn now being in glibc +________________________________________________________________________ == NEXT RELEASE ======================================================== ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ - interserver xmpp /me expects no leading newline, but pidgin recently @@ -1079,6 +1085,9 @@ cel'>< ________________________________________________________________________ == RELEASE INSTALLER =================================================== ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ++ the psyced script could check if psyced.ini has been changed recently + and autorun psyconf? or maybe just spit out a warning.. + - _charset_console can still lead to unexpected convert_charset errors when outputting random data. convert_charset must be non-fatal here! diff --git a/world/net/spyc/circuit.c b/world/net/spyc/circuit.c index 1c80fd3..4c0383c 100644 --- a/world/net/spyc/circuit.c +++ b/world/net/spyc/circuit.c @@ -25,7 +25,7 @@ volatile string netloc; // this is completely anti-psyc. it should take mcs as arguments // and look up the actual message from textdb.. FIXME -#define CIRCUITERROR(reason) { debug_message("SPYC CIRCUIT: " reason "\n"); \ +#define CIRCUITERROR(reason) { \ croak("_error_circuit", "circuit error: " \ reason); \ return 0; \ @@ -55,9 +55,12 @@ void feed(string data) { // yes, this is a funny implementation of croak // it does not use msg(). Yes, that is intended varargs mixed croak(string mc, string data, vamapping vars, vamixed source) { + PT(("croak(%O) in %O (%O)\n", mc, ME, query_ip_name())) + unless (data) data = T(mc, ""); binary_message(sprintf("\n%s\n%s\n|\n", mc, data)); - remove_interactive(ME); - destruct(ME); + // right behaviour for all croaks!? + remove_interactive(ME); +// destruct(ME); return 0; } diff --git a/world/net/spyc/parse.c b/world/net/spyc/parse.c index e4972dc..316e61b 100644 --- a/world/net/spyc/parse.c +++ b/world/net/spyc/parse.c @@ -15,21 +15,21 @@ int may_parse_more; array(mixed) tvars; mapping hvars; -// this is completely anti-psyc. it should take mcs as arguments -// and look up the actual message from textdb.. FIXME -#define PARSEERROR(reason) { debug_message("PSYC PARSE ERROR: " reason "\n"); \ - croak("_error_syntax_broken", "Failed parsing: " \ - reason); \ - return 0; \ - } - - +// being faded out in favor of regular croak() +#define PARSEERROR(reason) { \ + croak("_error_syntax_broken", \ + "Failed parsing: " reason); \ + return 0; } + #define DELIM S_GLYPH_PACKET_DELIMITER "\n" #define C_LINEFEED '\n' #define MVAR_GLYPH 0 #define MVAR_STATE 1 #define MVAR_VALUE 2 +#ifndef PSYC_UDP +# define QUIT remove_interactive(ME); return 0; +#endif step(); // prototype @@ -76,9 +76,7 @@ void feed(string data) { // overload this as needed -varargs mixed croak(string mc, string data, vamapping vars, vamixed source) { - return 0; -} +varargs mixed croak(string mc, string data, vamapping vars) { return 0; } // called when a complete packet has arrived @@ -101,16 +99,18 @@ mapping process_header(mixed varops) { case C_GLYPH_MODIFIER_DIMINISH: case C_GLYPH_MODIFIER_QUERY: case C_GLYPH_MODIFIER_ASSIGN: - PARSEERROR("header modifier with glyph other than ':', this is not implemented") - break; + croak("_failure_unavailable_state"); + QUIT default: - PARSEERROR("header modifier with unknown glyph") - break; + croak("_failure_unknown_glyph"); + QUIT } - // FIXME: not every legal varname is a mmp varname + // FIXME: not every legal varname is a routing varname // look at shared_memory("routing") if (!legal_keyword(vname) || abbrev("_INTERNAL", vname)) { - PARSEERROR("illegal varname in header") + croak("_error_illegal_protocol_variable", 0, + ([ "_variable_name": vname ])); + return 0; } } return vars; @@ -158,7 +158,8 @@ void parse_header() { buffer = buffer[1..]; break; default: - PARSEERROR("noglyph") + croak("_error_syntax_expected_routing"); + QUIT } fit = sscanf(buffer, "%.1s%t", vname); if (fit != 1) { @@ -222,6 +223,7 @@ void parse_psyc() { PARSEERROR("negative binary length") } if (strlen(body_buffer) < len) { + // ouch, this is a problem here PARSEERROR("not enough to read binary arg, may not happen") } vvalue = body_buffer[..len-1]; @@ -290,9 +292,9 @@ void parse_content() { } fit = sscanf(body_buffer, "%.1s\n%.0s", method, body_buffer); if (fit != 2 || !legal_keyword(method)) { - croak("_error_illegal_method", - "That's not a valid method name."); - return; // NOTREACHED + croak("_error_illegal_method"); + // "That's not a valid method name."); + return; } // mhmm... why does body_buffer still contain the newline? @@ -359,8 +361,8 @@ void step() { first_response(); step(); } else { - croak("_error_syntax_initialization", - "The new protocol begins with a pipe and a line feed."); + croak("_error_syntax_initialization"); + // "The new protocol begins with a pipe and a line feed."); } break; default: // uhm... if we ever get here this is the programmers fault