From 7471e4fcf9ee134262e6fa8c010a3f060c0140b9 Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Fri, 4 Jun 2004 14:03:15 +0000 Subject: [PATCH] Fixed stack overflow under Windows on resubmit of entry SVN revision: 880 --- src/elogd.c | 91 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 51 insertions(+), 40 deletions(-) diff --git a/src/elogd.c b/src/elogd.c index c0500533..8ed54d58 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -6,6 +6,9 @@ Contents: Web server program for Electronic Logbook ELOG $Log$ + Revision 1.329 2004/06/04 14:03:15 midas + Fixed stack overflow under Windows on resubmit of entry + Revision 1.328 2004/05/21 13:02:51 midas Fixed bug with date attributes and 'subst on edit' @@ -4248,20 +4251,23 @@ int el_correct_links(LOGBOOK * lbs, int old_id, int new_id) This routine corrects that. */ { int i, i1, n, n1, size; - char date[80], attrib[MAX_N_ATTR][NAME_LENGTH], text[TEXT_SIZE], - in_reply_to[80], reply_to[MAX_REPLY_TO * 10], encoding[80], locked_by[256]; + char date[80], *attrib, *text, in_reply_to[80], reply_to[MAX_REPLY_TO * 10], encoding[80], locked_by[256]; char list[MAX_N_ATTR][NAME_LENGTH], list1[MAX_N_ATTR][NAME_LENGTH]; - char att_file[MAX_ATTACHMENTS][256]; + char *att_file; - el_retrieve(lbs, new_id, date, attr_list, attrib, lbs->n_attr, NULL, 0, in_reply_to, - reply_to, att_file, encoding, locked_by); + attrib = malloc(MAX_N_ATTR * NAME_LENGTH); + text = malloc(TEXT_SIZE); + att_file = malloc(MAX_ATTACHMENTS * 256); + + el_retrieve(lbs, new_id, date, attr_list, (void *) attrib, lbs->n_attr, NULL, 0, in_reply_to, + reply_to, (void *)att_file, encoding, locked_by); /* go through in_reply_to list */ n = strbreak(in_reply_to, list, MAX_N_ATTR, ","); for (i = 0; i < n; i++) { - size = sizeof(text); - el_retrieve(lbs, atoi(list[i]), date, attr_list, attrib, lbs->n_attr, - text, &size, in_reply_to, reply_to, att_file, encoding, locked_by); + size = TEXT_SIZE; + el_retrieve(lbs, atoi(list[i]), date, attr_list, (void *)attrib, lbs->n_attr, + text, &size, in_reply_to, reply_to, (void *)att_file, encoding, locked_by); n1 = strbreak(reply_to, list1, MAX_N_ATTR, ","); reply_to[0] = 0; @@ -4276,19 +4282,19 @@ This routine corrects that. */ strcat(reply_to, ", "); } - el_submit(lbs, atoi(list[i]), TRUE, date, attr_list, attrib, lbs->n_attr, - text, in_reply_to, reply_to, encoding, att_file, TRUE, locked_by); + el_submit(lbs, atoi(list[i]), TRUE, date, attr_list, (void *)attrib, lbs->n_attr, + text, in_reply_to, reply_to, encoding, (void *)att_file, TRUE, locked_by); } - el_retrieve(lbs, new_id, date, attr_list, attrib, lbs->n_attr, NULL, 0, in_reply_to, - reply_to, att_file, encoding, locked_by); + el_retrieve(lbs, new_id, date, attr_list, (void *)attrib, lbs->n_attr, NULL, 0, in_reply_to, + reply_to, (void *)att_file, encoding, locked_by); /* go through reply_to list */ n = strbreak(reply_to, list, MAX_N_ATTR, ","); for (i = 0; i < n; i++) { size = sizeof(text); - el_retrieve(lbs, atoi(list[i]), date, attr_list, attrib, lbs->n_attr, - text, &size, in_reply_to, reply_to, att_file, encoding, locked_by); + el_retrieve(lbs, atoi(list[i]), date, attr_list, (void *)attrib, lbs->n_attr, + text, &size, in_reply_to, reply_to, (void *)att_file, encoding, locked_by); n1 = strbreak(in_reply_to, list1, MAX_N_ATTR, ","); in_reply_to[0] = 0; @@ -4303,10 +4309,14 @@ This routine corrects that. */ strcat(in_reply_to, ", "); } - el_submit(lbs, atoi(list[i]), TRUE, date, attr_list, attrib, lbs->n_attr, - text, in_reply_to, reply_to, encoding, att_file, TRUE, locked_by); + el_submit(lbs, atoi(list[i]), TRUE, date, attr_list, (void *)attrib, lbs->n_attr, + text, in_reply_to, reply_to, encoding, (void *)att_file, TRUE, locked_by); } + free(text); + free(attrib); + free(att_file); + return EL_SUCCESS; } @@ -11913,34 +11923,35 @@ void show_page_filters(LOGBOOK * lbs, int n_msg, int page_n, BOOL mode_commands, i = atoi(getparam(list[index])); - rsprintf("