diff --git a/src/server/ChangeLog b/src/server/ChangeLog index dcf85cf9f85cdf524e9b33ccb62f5ab153e6f7fb..2d9baf53e6869ab9e7a764fee3aad3bc4b6bcffd 100644 --- a/src/server/ChangeLog +++ b/src/server/ChangeLog @@ -1,3 +1,10 @@ +Sat May 23 19:57:17 1992 Per Cederqvist (ceder@robin) + + * text.c (add_comment, add_footnote): Disallow texts to be + comments/footnotes to themselves, since that would trigger a bug + (the misc-list that is created would be erronous. A proper + misc-info-list handling package should be written instead. + Tue May 19 01:06:50 1992 Per Cederqvist (ceder@lysator) * Makefile (tags): Search libraries/libisc-new. diff --git a/src/server/text.c b/src/server/text.c index 0d079070721300f97f1c143252c8f9871db4f4ae..180571a11d2d12b7e4a7d37e4fc9557f9c73db9f 100644 --- a/src/server/text.c +++ b/src/server/text.c @@ -1,5 +1,5 @@ /* - * $Id: text.c,v 0.16 1992/02/26 18:44:55 ceder Exp $ + * $Id: text.c,v 0.17 1992/05/23 18:03:35 ceder Exp $ * Copyright (C) 1991 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -28,7 +28,7 @@ * All atomic calls that deals with texts. */ -static char *rcsid = "$Id: text.c,v 0.16 1992/02/26 18:44:55 ceder Exp $"; +static char *rcsid = "$Id: text.c,v 0.17 1992/05/23 18:03:35 ceder Exp $"; #include <time.h> #include <stdlib.h> @@ -2120,19 +2120,30 @@ sub_recipient( Text_no text_no, * Add a comment-link between two existing texts. */ extern Success -add_comment( Text_no comment, - Text_no comment_to ) +add_comment(Text_no comment, + Text_no comment_to) { - Text_stat *text_s, *parent_s; + Text_stat *child_s, *parent_s; CHK_LOGIN(FAILURE); - GET_T_STAT(text_s, comment, FAILURE); + + /* The following code can not cope with a text that is a comment + to itself. That is considered to be a bug. Work around it for + now, until a proper misc-info-list handling package is written. + FIXME +++ /// */ + if (comment == comment_to) + { + kom_errno = KOM_INDEX_OUT_OF_RANGE; + return FAILURE; + } + + GET_T_STAT(child_s, comment, FAILURE); GET_T_STAT(parent_s, comment_to, FAILURE); if ( check_comm(parent_s) != OK ) return FAILURE; - if ( !text_read_access(comment, text_s) ) + if ( !text_read_access(comment, child_s) ) { kom_errno = KOM_NO_SUCH_TEXT; return FAILURE; @@ -2148,12 +2159,12 @@ add_comment( Text_no comment, if ( do_add_comment(comment, comment_to) != OK) return FAILURE; - if ( text_s->author != ACTPERS ) - ADD_MISC(text_s, sent_by, sender, ACTPERS); + if ( child_s->author != ACTPERS ) + ADD_MISC(child_s, sent_by, sender, ACTPERS); - ADD_MISC(text_s, sent_at, sent_at, time(NULL)); + ADD_MISC(child_s, sent_at, sent_at, time(NULL)); - mark_text_as_changed( comment ); + mark_text_as_changed (comment); return OK; } @@ -2222,6 +2233,16 @@ add_footnote( Text_no footnote, GET_T_STAT(text_s, footnote, FAILURE); GET_T_STAT(parent_s, footnote_to, FAILURE); + /* The following code can not cope with a text that is a footnote + to itself. That is considered to be a bug. Work around it for + now, until a proper misc-info-list handling package is written. + FIXME /// +++ */ + if (footnote == footnote_to) + { + kom_errno = KOM_INDEX_OUT_OF_RANGE; + return FAILURE; + } + if ( !text_read_access(footnote, text_s) || !text_read_access(footnote_to, parent_s) ) {