From d584d5fbe9eb077194c620fae33ac7db79d4d809 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 18 Nov 2001 01:41:09 +0000 Subject: [PATCH] * Brought over the newer string tokenizer from Citadel * Upgraded all the generic string buffers to 4096 bytes, using the Citadel server's convention of #define SIZ 4096 --- webcit/ChangeLog | 6 +- webcit/auth.c | 21 +++--- webcit/context_loop.c | 4 +- webcit/cookie_conversion.c | 6 +- webcit/graphics.c | 4 +- webcit/mainmenu.c | 4 +- webcit/messages.c | 38 +++++------ webcit/netconf.c | 48 ++++++------- webcit/paging.c | 12 ++-- webcit/roomops.c | 44 ++++++------ webcit/serv_func.c | 10 +-- webcit/siteconfig.c | 4 +- webcit/subst.c | 2 +- webcit/sysmsgs.c | 4 +- webcit/tcp_sockets.c | 4 +- webcit/tools.c | 134 +++++++++++++++++++++++++------------ webcit/userlist.c | 8 +-- webcit/webcit.c | 36 +++++----- webcit/webcit.h | 23 ++++--- webcit/webserver.c | 2 +- webcit/who.c | 8 +-- 21 files changed, 239 insertions(+), 183 deletions(-) diff --git a/webcit/ChangeLog b/webcit/ChangeLog index 5a2c0c853..2221f1066 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,4 +1,9 @@ $Log$ +Revision 301.9 2001/11/18 01:41:09 ajc +* Brought over the newer string tokenizer from Citadel +* Upgraded all the generic string buffers to 4096 bytes, using the Citadel + server's convention of #define SIZ 4096 + Revision 301.8 2001/11/14 03:20:22 ajc * Add some more of the newer config settings to the site config screen @@ -631,4 +636,3 @@ Sun Dec 6 19:50:55 EST 1998 Art Cancro 1998-12-03 Nathan Bryant * webserver.c: warning fix - diff --git a/webcit/auth.c b/webcit/auth.c index c7ab697b1..a5177ced1 100644 --- a/webcit/auth.c +++ b/webcit/auth.c @@ -28,7 +28,6 @@ #include #include "webcit.h" - char *axdefs[] = { "Deleted", @@ -45,7 +44,7 @@ char *axdefs[] = */ void display_login(char *mesg) { - char buf[256]; + char buf[SIZ]; output_headers(3); @@ -84,7 +83,7 @@ void become_logged_in(char *user, char *pass, char *serv_response) void do_login(void) { - char buf[256]; + char buf[SIZ]; int need_regi = 0; @@ -159,7 +158,7 @@ void end_webcit_session(void) { void do_logout(void) { - char buf[256]; + char buf[SIZ]; strcpy(WC->wc_username, ""); strcpy(WC->wc_password, ""); @@ -190,9 +189,9 @@ void do_logout(void) */ void validate(void) { - char cmd[256]; - char user[256]; - char buf[256]; + char cmd[SIZ]; + char user[SIZ]; + char buf[SIZ]; int a; output_headers(1); @@ -270,7 +269,7 @@ void validate(void) */ void display_reg(int during_login) { - char buf[256]; + char buf[SIZ]; int a; output_headers(1); @@ -341,7 +340,7 @@ void display_reg(int during_login) */ void register_user(void) { - char buf[256]; + char buf[SIZ]; if (strcmp(bstr("action"), "Register")) { display_error("Cancelled. Registration was not saved."); @@ -378,7 +377,7 @@ void register_user(void) */ void display_changepw(void) { - char buf[256]; + char buf[SIZ]; output_headers(1); @@ -410,7 +409,7 @@ void display_changepw(void) */ void changepw(void) { - char buf[256]; + char buf[SIZ]; char newpass1[32], newpass2[32]; if (strcmp(bstr("action"), "Change")) { diff --git a/webcit/context_loop.c b/webcit/context_loop.c index 83448ffbe..03ec66e1a 100644 --- a/webcit/context_loop.c +++ b/webcit/context_loop.c @@ -157,7 +157,7 @@ int req_gets(int sock, char *buf, char *hold) int lingering_close(int fd) { - char buf[256]; + char buf[SIZ]; int i; fd_set set; struct timeval tv, start; @@ -222,7 +222,7 @@ void context_loop(int sock) struct httprequest *req = NULL; struct httprequest *last = NULL; struct httprequest *hptr; - char buf[256], hold[256]; + char buf[SIZ], hold[SIZ]; int desired_session = 0; int got_cookie = 0; struct wcsession *TheSession, *sptr; diff --git a/webcit/cookie_conversion.c b/webcit/cookie_conversion.c index 22bdb58a0..dd39f1bb1 100644 --- a/webcit/cookie_conversion.c +++ b/webcit/cookie_conversion.c @@ -24,7 +24,7 @@ #define FALSE 0 typedef unsigned char byte; /* Byte type */ -static byte dtable[256]; /* base64 encode / decode table */ +static byte dtable[SIZ]; /* base64 encode / decode table */ /* * decode_base64() and encode_base64() are adaptations of code by @@ -157,7 +157,7 @@ void decode_base64(char *dest, char *source) */ void stuff_to_cookie(char *cookie, int session, char *user, char *pass, char *room) { - char buf[256]; + char buf[SIZ]; sprintf(buf, "%d|%s|%s|%s", session, user, pass, room); encode_base64(cookie, buf); @@ -169,7 +169,7 @@ void stuff_to_cookie(char *cookie, int session, char *user, char *pass, char *ro */ void cookie_to_stuff(char *cookie, int *session, char *user, char *pass, char *room) { - char buf[256]; + char buf[SIZ]; decode_base64(buf, cookie); diff --git a/webcit/graphics.c b/webcit/graphics.c index d2fa9994c..6593d9a05 100644 --- a/webcit/graphics.c +++ b/webcit/graphics.c @@ -22,7 +22,7 @@ void display_graphics_upload(char *description, char *check_cmd, char *uplurl) { - char buf[256]; + char buf[SIZ]; serv_puts(check_cmd); serv_gets(buf); @@ -57,7 +57,7 @@ void display_graphics_upload(char *description, char *check_cmd, char *uplurl) void do_graphics_upload(char *upl_cmd) { - char buf[256]; + char buf[SIZ]; int bytes_remaining; int pos = 0; int thisblock; diff --git a/webcit/mainmenu.c b/webcit/mainmenu.c index 5623d2aeb..5dce575ab 100644 --- a/webcit/mainmenu.c +++ b/webcit/mainmenu.c @@ -225,8 +225,8 @@ void display_generic(void) void do_generic(void) { - char buf[256]; - char gcontent[256]; + char buf[SIZ]; + char gcontent[SIZ]; char *junk; size_t len; diff --git a/webcit/messages.c b/webcit/messages.c index 55ad24e75..4bc642ba9 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -37,7 +37,7 @@ char buf[]; int pos; int start, end; char ench; - char urlbuf[256]; + char urlbuf[SIZ]; char outbuf[1024]; start = (-1); @@ -82,19 +82,19 @@ char buf[]; void read_message(long msgnum, int is_summary) { - char buf[256]; - char mime_partnum[256]; - char mime_filename[256]; - char mime_content_type[256]; - char mime_disposition[256]; + char buf[SIZ]; + char mime_partnum[SIZ]; + char mime_filename[SIZ]; + char mime_content_type[SIZ]; + char mime_disposition[SIZ]; int mime_length; char *mime_http = NULL; - char m_subject[256]; - char from[256]; - char node[256]; - char rfca[256]; + char m_subject[SIZ]; + char from[SIZ]; + char node[SIZ]; + char rfca[SIZ]; char reply_to[512]; - char now[256]; + char now[SIZ]; int format_type = 0; int nhdr = 0; int bq = 0; @@ -319,7 +319,7 @@ void read_message(long msgnum, int is_summary) { int load_msg_ptrs(servcmd) char *servcmd; { - char buf[256]; + char buf[SIZ]; int nummsgs; nummsgs = 0; @@ -342,7 +342,7 @@ char *servcmd; */ void readloop(char *oper) { - char cmd[256]; + char cmd[SIZ]; int a, b; int nummsgs; long startmsg; @@ -470,7 +470,7 @@ DONE: wDumpContent(1); */ void post_message(void) { - char buf[256]; + char buf[SIZ]; static long dont_post = (-1L); output_headers(1); @@ -533,7 +533,7 @@ void prompt_for_recipient() */ void display_enter(void) { - char buf[256]; + char buf[SIZ]; long now; struct tm *tm; @@ -599,7 +599,7 @@ DONE: wDumpContent(1); void delete_msg(void) { long msgid; - char buf[256]; + char buf[SIZ]; msgid = atol(bstr("msgid")); @@ -622,8 +622,8 @@ void delete_msg(void) void confirm_move_msg(void) { long msgid; - char buf[256]; - char targ[256]; + char buf[SIZ]; + char targ[SIZ]; msgid = atol(bstr("msgid")); @@ -670,7 +670,7 @@ void confirm_move_msg(void) void move_msg(void) { long msgid; - char buf[256]; + char buf[SIZ]; msgid = atol(bstr("msgid")); diff --git a/webcit/netconf.c b/webcit/netconf.c index ee2095031..3a3d80e8c 100644 --- a/webcit/netconf.c +++ b/webcit/netconf.c @@ -29,15 +29,15 @@ struct sharelist { struct sharelist *next; - char shname[256]; + char shname[SIZ]; }; void display_edit_node(void) { - char buf[256]; - char node[256]; - char sroom[256]; + char buf[SIZ]; + char node[SIZ]; + char sroom[SIZ]; strcpy(node, bstr("node")); @@ -82,8 +82,8 @@ void display_edit_node(void) void display_netconf(void) { - char buf[256]; - char node[256]; + char buf[SIZ]; + char node[SIZ]; output_headers(1); wprintf("
"); @@ -125,8 +125,8 @@ void display_netconf(void) void display_confirm_unshare(void) { - char node[256]; - char sroom[256]; + char node[SIZ]; + char sroom[SIZ]; output_headers(1); wprintf("
"); @@ -153,7 +153,7 @@ void display_confirm_unshare(void) void display_confirm_delete_node(void) { - char node[256]; + char node[SIZ]; output_headers(1); wprintf("
"); @@ -175,8 +175,8 @@ void display_confirm_delete_node(void) void delete_node(void) { - char node[256]; - char buf[256]; + char node[SIZ]; + char buf[SIZ]; strcpy(node, bstr("node")); sprintf(buf, "NSET deletenode|%s", node); @@ -195,9 +195,9 @@ void delete_node(void) void unshare(void) { - char node[256]; - char sroom[256]; - char buf[256]; + char node[SIZ]; + char sroom[SIZ]; + char buf[SIZ]; strcpy(node, bstr("node")); strcpy(sroom, bstr("sroom")); @@ -242,9 +242,9 @@ void display_add_node(void) void add_node(void) { - char node[256]; - char buf[256]; - char sc[256]; + char node[SIZ]; + char buf[SIZ]; + char sc[SIZ]; strcpy(node, bstr("node")); strcpy(sc, bstr("sc")); @@ -268,9 +268,9 @@ void add_node(void) void display_share(void) { - char buf[256]; - char node[256]; - char sroom[256]; + char buf[SIZ]; + char node[SIZ]; + char sroom[SIZ]; struct sharelist *shlist = NULL; struct sharelist *shptr; int already_shared; @@ -342,10 +342,10 @@ void display_share(void) void share(void) { - char node[256]; - char buf[256]; - char sc[256]; - char sroom[256]; + char node[SIZ]; + char buf[SIZ]; + char sc[SIZ]; + char sroom[SIZ]; strcpy(node, bstr("node")); strcpy(sc, bstr("sc")); diff --git a/webcit/paging.c b/webcit/paging.c index 797ae0219..9b506109f 100644 --- a/webcit/paging.c +++ b/webcit/paging.c @@ -27,7 +27,7 @@ */ void display_page(void) { - char recp[256]; + char recp[SIZ]; strcpy(recp, bstr("recp")); @@ -69,9 +69,9 @@ void display_page(void) */ void page_user(void) { - char recp[256]; - char sc[256]; - char buf[256]; + char recp[SIZ]; + char sc[SIZ]; + char buf[SIZ]; output_headers(1); @@ -135,8 +135,8 @@ void do_chat(void) */ void page_popup(void) { - char buf[256]; - char pagefrom[256]; + char buf[SIZ]; + char pagefrom[SIZ]; /* suppress express message check, do headers but no fake frames */ output_headers(0x08 | 0x03); diff --git a/webcit/roomops.c b/webcit/roomops.c index f249351a6..1a3c2960c 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -28,7 +28,7 @@ -char floorlist[128][256]; +char floorlist[128][SIZ]; /* @@ -37,7 +37,7 @@ char floorlist[128][256]; void load_floorlist(void) { int a; - char buf[256]; + char buf[SIZ]; for (a = 0; a < 128; ++a) floorlist[a][0] = 0; @@ -150,7 +150,7 @@ int rordercmp(struct roomlisting *r1, struct roomlisting *r2) */ void listrms(char *variety) { - char buf[256]; + char buf[SIZ]; int num_rooms = 0; struct roomlisting *rl = NULL; @@ -220,7 +220,7 @@ void listrms(char *variety) void list_all_rooms_by_floor(void) { int a; - char buf[256]; + char buf[SIZ]; load_floorlist(); @@ -287,7 +287,7 @@ void zapped_list(void) */ void readinfo(void) { - char buf[256]; + char buf[SIZ]; serv_puts("RINF"); serv_gets(buf); @@ -307,7 +307,7 @@ void readinfo(void) * another room. */ void embed_room_graphic(void) { - char buf[256]; + char buf[SIZ]; serv_puts("OIMG _roompic_"); serv_gets(buf); @@ -339,7 +339,7 @@ void embed_newmail_button(void) { void embed_room_banner(char *got) { - char fakegot[256]; + char fakegot[SIZ]; /* We need to have the information returned by a GOTO server command. * If it isn't supplied, we fake it by issuing our own GOTO. @@ -377,7 +377,7 @@ void embed_room_banner(char *got) { */ void gotoroom(char *gname, int display_name) { - char buf[256]; + char buf[SIZ]; static long ls = (-1L); @@ -486,7 +486,7 @@ char *pop_march(int desired_floor) */ void gotonext(void) { - char buf[256]; + char buf[SIZ]; struct march *mptr, *mptr2; char next_room[32]; @@ -556,7 +556,7 @@ void smart_goto(char *next_room) { */ void slrp_highest(void) { - char buf[256]; + char buf[SIZ]; /* set pointer */ serv_puts("SLRP HIGHEST"); @@ -573,7 +573,7 @@ void slrp_highest(void) */ void ungoto(void) { - char buf[256]; + char buf[SIZ]; if (!strcmp(WC->ugname, "")) { smart_goto(WC->wc_roomname); @@ -599,7 +599,7 @@ void ungoto(void) */ void display_editroom(void) { - char buf[256]; + char buf[SIZ]; char er_name[20]; char er_password[10]; char er_dirname[15]; @@ -781,7 +781,7 @@ void display_editroom(void) */ void editroom(void) { - char buf[256]; + char buf[SIZ]; char er_name[20]; char er_password[10]; char er_dirname[15]; @@ -927,7 +927,7 @@ void editroom(void) */ void display_whok(void) { - char buf[256], room[256], username[256]; + char buf[SIZ], room[SIZ], username[SIZ]; serv_puts("GETR"); serv_gets(buf); @@ -1003,7 +1003,7 @@ void display_whok(void) void display_entroom(void) { int i; - char buf[256]; + char buf[SIZ]; serv_puts("CRE8 0"); serv_gets(buf); @@ -1074,7 +1074,7 @@ void display_entroom(void) */ void entroom(void) { - char buf[256]; + char buf[SIZ]; char er_name[20]; char er_type[20]; char er_password[10]; @@ -1156,7 +1156,7 @@ void display_private(char *rname, int req_pass) void goto_private(void) { char hold_rm[32]; - char buf[256]; + char buf[SIZ]; if (strcasecmp(bstr("sc"), "OK")) { display_main_menu(); @@ -1214,8 +1214,8 @@ void display_zap(void) */ void zap(void) { - char buf[256]; - char final_destination[256]; + char buf[SIZ]; + char final_destination[SIZ]; /* If the forget-room routine fails for any reason, we fall back * to the current room; otherwise, we go to the Lobby @@ -1248,7 +1248,7 @@ void zap(void) */ void confirm_delete_room(void) { - char buf[256]; + char buf[SIZ]; serv_puts("KILL 0"); serv_gets(buf); @@ -1282,8 +1282,8 @@ void confirm_delete_room(void) */ void delete_room(void) { - char buf[256]; - char sc[256]; + char buf[SIZ]; + char sc[SIZ]; strcpy(sc, bstr("sc")); diff --git a/webcit/serv_func.c b/webcit/serv_func.c index 38b4fdd80..be9e41323 100644 --- a/webcit/serv_func.c +++ b/webcit/serv_func.c @@ -36,7 +36,7 @@ struct serv_info serv_info; */ void get_serv_info(char *browser_host, char *user_agent) { - char buf[256]; + char buf[SIZ]; int a; serv_printf("IDEN %d|%d|%d|%s|%s", @@ -100,14 +100,14 @@ void fmout(FILE * fp) int intext = 0; int bq = 0; - char buf[256]; + char buf[SIZ]; wprintf("
\n"); while (1) { if (fp == NULL) serv_gets(buf); if (fp != NULL) { - if (fgets(buf, 256, fp) == NULL) + if (fgets(buf, SIZ, fp) == NULL) strcpy(buf, "000"); buf[strlen(buf) - 1] = 0; } @@ -153,7 +153,7 @@ void fmout(FILE * fp) */ void text_to_server(char *ptr) { - char buf[256]; + char buf[SIZ]; int ch, a, pos; pos = 0; @@ -197,7 +197,7 @@ void text_to_server(char *ptr) */ void server_to_text() { - char buf[256]; + char buf[SIZ]; int count = 0; diff --git a/webcit/siteconfig.c b/webcit/siteconfig.c index 50bf0a4e0..5f3ba1144 100644 --- a/webcit/siteconfig.c +++ b/webcit/siteconfig.c @@ -31,7 +31,7 @@ void display_siteconfig(void) { - char buf[256]; + char buf[SIZ]; int i; output_headers(1); @@ -208,7 +208,7 @@ void display_siteconfig(void) void siteconfig(void) { - char buf[256]; + char buf[SIZ]; if (strcasecmp(bstr("sc"), "OK")) { display_main_menu(); diff --git a/webcit/subst.c b/webcit/subst.c index 6e348dae3..23d83386e 100644 --- a/webcit/subst.c +++ b/webcit/subst.c @@ -95,7 +95,7 @@ void svcallback(char *keyname, void (*fcn_ptr)() ) * back end for print_value_of() ... does a server command */ void pvo_do_cmd(char *servcmd) { - char buf[256]; + char buf[SIZ]; serv_puts(servcmd); serv_gets(buf); diff --git a/webcit/sysmsgs.c b/webcit/sysmsgs.c index 5934e3db1..87604bdd3 100644 --- a/webcit/sysmsgs.c +++ b/webcit/sysmsgs.c @@ -34,7 +34,7 @@ void display_edit(char *description, char *check_cmd, char *read_cmd, char *save_cmd) { - char buf[256]; + char buf[SIZ]; serv_puts(check_cmd); serv_gets(buf); @@ -76,7 +76,7 @@ void display_edit(char *description, char *check_cmd, */ void save_edit(char *description, char *enter_cmd, int regoto) { - char buf[256]; + char buf[SIZ]; if (strcmp(bstr("sc"), "Save")) { output_headers(1); diff --git a/webcit/tcp_sockets.c b/webcit/tcp_sockets.c index 9501a79fb..d457e71c6 100644 --- a/webcit/tcp_sockets.c +++ b/webcit/tcp_sockets.c @@ -198,7 +198,7 @@ void serv_write(char *buf, int nbytes) */ void serv_puts(char *string) { - char buf[256]; + char buf[SIZ]; sprintf(buf, "%s\n", string); serv_write(buf, strlen(buf)); @@ -211,7 +211,7 @@ void serv_puts(char *string) void serv_printf(const char *format,...) { va_list arg_ptr; - char buf[256]; + char buf[SIZ]; va_start(arg_ptr, format); vsprintf(buf, format, arg_ptr); diff --git a/webcit/tools.c b/webcit/tools.c index 0bf0dcc24..d85121150 100644 --- a/webcit/tools.c +++ b/webcit/tools.c @@ -49,68 +49,103 @@ char *safestrncpy(char *dest, const char *src, size_t n) } + /* - * num_parms() - discover number of parameters... + * num_tokens() - discover number of parameters/tokens in a string */ -int num_parms(char *source) -{ +int num_tokens(char *source, char tok) { int a; int count = 1; - for (a = 0; a < strlen(source); ++a) - if (source[a] == '|') - ++count; - return (count); + if (source == NULL) return(0); + for (a=0; a= n) { - strcpy(dest, ""); + if (strlen(source)==0) { return; + } + + for (i=0; i 0) && (buf[0] != '|')); - if (buf[0] == '|') - strcpy(buf, &buf[1]); - for (count = 0; count < strlen(buf); ++count) - if (buf[count] == '|') - buf[count] = 0; - strcpy(dest, buf); + + if (end < 0) end = strlen(source); + + printf("%d .. %d\n", start, end); + + strcpy(&source[start], &source[end]); } + + + /* * extract_int() - extract an int parm w/o supplying a buffer */ int extract_int(char *source, int parmnum) { - char buf[256]; - - extract(buf, source, parmnum); - return (atoi(buf)); + char buf[SIZ]; + + extract_token(buf, source, parmnum, '|'); + return(atoi(buf)); } /* @@ -118,13 +153,26 @@ int extract_int(char *source, int parmnum) */ long extract_long(char *source, long int parmnum) { - char buf[256]; - - extract(buf, source, parmnum); - return (atol(buf)); + char buf[SIZ]; + + extract_token(buf, source, parmnum, '|'); + return(atol(buf)); } + + + + + + + + + + + + + /* * check for the presence of a character within a string (returns count) */ diff --git a/webcit/userlist.c b/webcit/userlist.c index bcc96edb0..8fd97db35 100644 --- a/webcit/userlist.c +++ b/webcit/userlist.c @@ -32,8 +32,8 @@ struct namelist { */ void userlist(void) { - char buf[256]; - char fl[256]; + char buf[SIZ]; + char fl[SIZ]; struct tm *tmbuf; long lc; struct namelist *bio = NULL; @@ -109,8 +109,8 @@ void userlist(void) */ void showuser(void) { - char who[256]; - char buf[256]; + char who[SIZ]; + char buf[SIZ]; int have_pic; output_headers(1); diff --git a/webcit/webcit.c b/webcit/webcit.c index 243edf6c8..6e884e88a 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -65,7 +65,7 @@ void unescape_input(char *buf) void addurls(char *url) { char *up, *ptr; - char buf[256]; + char buf[SIZ]; int a, b; struct urlcontent *u; @@ -287,11 +287,11 @@ void urlescputs(char *strbuf) */ void output_headers(int controlcode) { - char cookie[256]; + char cookie[SIZ]; int print_standard_html_head = 0; int refresh30 = 0; int suppress_check = 0; - char httpnow[256]; + char httpnow[SIZ]; static int pageseq = 0; print_standard_html_head = controlcode & 0x03; @@ -389,7 +389,7 @@ void http_redirect(char *whichpage) { void check_for_express_messages() { - char buf[256]; + char buf[SIZ]; serv_puts("NOOP"); serv_gets(buf); @@ -451,7 +451,7 @@ void output_static(char *what) */ void output_image() { - char buf[256]; + char buf[SIZ]; char xferbuf[4096]; off_t bytes; off_t thisblock; @@ -501,12 +501,12 @@ void output_image() */ void output_mimepart() { - char buf[256]; + char buf[SIZ]; char xferbuf[4096]; off_t bytes; off_t thisblock; off_t accomplished = 0L; - char content_type[256]; + char content_type[SIZ]; serv_printf("OPNA %s|%s", bstr("msgnum"), bstr("partnum")); serv_gets(buf); @@ -648,9 +648,9 @@ void upload_handler(char *name, char *filename, char *partnum, char *disp, */ void session_loop(struct httprequest *req) { - char cmd[256]; - char action[256]; - char buf[256]; + char cmd[SIZ]; + char action[SIZ]; + char buf[SIZ]; int a, b; int ContentLength = 0; int BytesRead; @@ -658,18 +658,18 @@ void session_loop(struct httprequest *req) char *content; char *content_end; struct httprequest *hptr; - char browser_host[256]; - char user_agent[256]; + char browser_host[SIZ]; + char user_agent[SIZ]; /* We stuff these with the values coming from the client cookies, * so we can use them to reconnect a timed out session if we have to. */ - char c_host[256]; - char c_port[256]; - char c_username[256]; - char c_password[256]; - char c_roomname[256]; - char cookie[256]; + char c_host[SIZ]; + char c_port[SIZ]; + char c_username[SIZ]; + char c_password[SIZ]; + char c_roomname[SIZ]; + char cookie[SIZ]; strcpy(c_host, defaulthost); strcpy(c_port, defaultport); diff --git a/webcit/webcit.h b/webcit/webcit.h index 5bdbd4158..b0e25f4f8 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -1,5 +1,7 @@ /* $Id$ */ +#define SIZ 4096 /* generic buffer size */ + #define TRACE fprintf(stderr, "Checkpoint: %s, %d\n", __FILE__, __LINE__) #define SLEEPING 180 /* TCP connection timeout */ @@ -40,7 +42,7 @@ struct httprequest { struct httprequest *next; - char line[256]; + char line[SIZ]; }; struct urlcontent { @@ -58,7 +60,7 @@ struct serv_info { int serv_rev_level; char serv_bbs_city[64]; char serv_sysadm[64]; - char serv_moreprompt[256]; + char serv_moreprompt[SIZ]; int serv_ok_floors; }; @@ -117,9 +119,9 @@ enum { struct wcsession { struct wcsession *next; /* Linked list */ int wc_session; /* WebCit session ID */ - char wc_username[256]; - char wc_password[256]; - char wc_roomname[256]; + char wc_username[SIZ]; + char wc_password[SIZ]; + char wc_roomname[SIZ]; int connected; int logged_in; int axlevel; @@ -147,13 +149,14 @@ struct wcsession { struct wcsubst *vars; }; - +#define extract(dest,source,parmnum) extract_token(dest,source,parmnum,'|') +#define num_parms(source) num_tokens(source, '|') #define WC ((struct wcsession *)pthread_getspecific(MyConKey)) extern pthread_key_t MyConKey; struct serv_info serv_info; -extern char floorlist[128][256]; +extern char floorlist[128][SIZ]; extern char *axdefs[]; extern char *defaulthost, *defaultport; extern char *server_cookie; @@ -191,14 +194,13 @@ char *urlesc(char *); void urlescputs(char *); void output_headers(int); void wprintf(const char *format,...); -void extract(char *dest, char *source, int parmnum); -int extract_int(char *source, int parmnum); void output_static(char *what); void stresc(char *target, char *strbuf, int nbsp); void escputs(char *strbuf); void url(char *buf); void escputs1(char *strbuf, int nbsp); long extract_long(char *source, long int parmnum); +int extract_int(char *source, int parmnum); void dump_vars(void); void embed_main_menu(void); void serv_read(char *buf, int bytes); @@ -281,3 +283,6 @@ void svcallback(char *keyname, void (*fcn_ptr)() ); void do_template(void *templatename); int lingering_close(int fd); char *memreadline(char *start, char *buf, int maxlen); +int num_tokens (char *source, char tok); +void extract_token(char *dest, char *source, int parmnum, char separator); +void remove_token(char *source, int parmnum, char separator); diff --git a/webcit/webserver.c b/webcit/webserver.c index 2f05519fa..266cd6929 100644 --- a/webcit/webserver.c +++ b/webcit/webserver.c @@ -240,7 +240,7 @@ int main(int argc, char **argv) freopen(tracefile, "r", stdin); break; case 'c': - server_cookie = malloc(256); + server_cookie = malloc(SIZ); if (server_cookie != NULL) { strcpy(server_cookie, "Set-cookie: wcserver="); if (gethostname( diff --git a/webcit/who.c b/webcit/who.c index 04c39bf19..c2690f936 100644 --- a/webcit/who.c +++ b/webcit/who.c @@ -31,8 +31,8 @@ */ void whobbs(void) { - char buf[256], sess, user[256], room[256], host[256], - realroom[256], realhost[256]; + char buf[SIZ], sess, user[SIZ], room[SIZ], host[SIZ], + realroom[SIZ], realhost[SIZ]; output_headers(7); @@ -126,7 +126,7 @@ void whobbs(void) void terminate_session(void) { - char buf[256]; + char buf[SIZ]; serv_printf("TERM %s", bstr("which_session")); serv_gets(buf); @@ -139,7 +139,7 @@ void terminate_session(void) */ void edit_me(void) { - char buf[256]; + char buf[SIZ]; if (!strcasecmp(bstr("sc"), "Change room name")) { serv_printf("RCHG %s", bstr("fake_roomname")); -- 2.30.2