From d59fe429a9eee5d4923a6fd3498244c2c899eee1 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Fri, 20 May 2011 17:37:05 -0400 Subject: [PATCH] Change to blog euid storage; note new definition in libcitadel.h --- citadel/modules/blog/serv_blog.c | 9 ++++++++- webcit/blogview_renderer.c | 13 ++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/citadel/modules/blog/serv_blog.c b/citadel/modules/blog/serv_blog.c index 5459898f7..fb95d613b 100644 --- a/citadel/modules/blog/serv_blog.c +++ b/citadel/modules/blog/serv_blog.c @@ -74,11 +74,18 @@ int blog_upload_beforesave(struct CtdlMessage *msg) { */ if (msg->cm_fields['E'] == NULL) { - char uuid[37]; + char uuid[BLOG_EUIDBUF_SIZE]; generate_uuid(uuid); msg->cm_fields['E'] = strdup(uuid); } + /* + * We also want to define a maximum length, whether we generated it or not. + */ + else if (strlen(msg->cm_fields['E']) >= BLOG_EUIDBUF_SIZE) { + msg->cm_fields['E'][BLOG_EUIDBUF_SIZE-1] = 0; + } + /* Now allow the save to complete. */ return(0); } diff --git a/webcit/blogview_renderer.c b/webcit/blogview_renderer.c index 8190cb8c8..25af87053 100644 --- a/webcit/blogview_renderer.c +++ b/webcit/blogview_renderer.c @@ -1,7 +1,7 @@ /* * Blog view renderer module for WebCit * - * Copyright (c) 1996-2010 by the citadel.org team + * Copyright (c) 1996-2011 by the citadel.org team * * This program is open source software. You can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -87,7 +87,7 @@ void blogpost_render_and_destroy(struct blogpost *bp) { struct bltr { int id; int refs; - StrBuf *euid; + char euid[BLOG_EUIDBUF_SIZE]; /* please do not change this to a StrBuf */ }; @@ -124,7 +124,7 @@ struct bltr blogview_learn_thread_references(long msgnum) StrBuf *Buf; StrBuf *r; int len; - struct bltr bltr = { 0, 0, NULL }; + struct bltr bltr = { 0, 0, "" } ; Buf = NewStrBuf(); r = NewStrBuf(); serv_printf("MSG0 %ld|1", msgnum); /* top level citadel headers only */ @@ -145,7 +145,7 @@ struct bltr blogview_learn_thread_references(long msgnum) } else if (!strncasecmp(ChrPtr(Buf), "exti=", 5)) { StrBufCutLeft(Buf, 5); /* trim the field name */ - bltr.euid = NewStrBufDup(Buf); + safestrncpy(bltr.euid, ChrPtr(Buf), sizeof(bltr.euid)); } } } @@ -170,9 +170,8 @@ int blogview_LoadMsgFromServer(SharedMessageStatus *Stat, b = blogview_learn_thread_references(Msg->msgnum); - if (b.euid != NULL) { - syslog(LOG_DEBUG, "\033[7m%s\033[0m", ChrPtr(b.euid)); - FreeStrBuf(&b.euid); + if (!IsEmptyStr(b.euid)) { + syslog(LOG_DEBUG, "\033[7m%s\033[0m", b.euid); } /* FIXME an optimization here -- one we ought to perform -- is to exit this -- 2.30.2