Fixed a stack smash in the wiki module
authorArt Cancro <ajc@uncensored.citadel.org>
Fri, 1 Jul 2011 03:47:18 +0000 (23:47 -0400)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Sep 2011 21:12:27 +0000 (21:12 +0000)
citadel/modules/wiki/serv_wiki.c
citadel/serv_extensions.c

index 62b2132d521d217c38037cc450a768e9c2d9bc11..4643d917d3a2669da8f5e890474cc77565fbc987 100644 (file)
@@ -281,11 +281,8 @@ int wiki_upload_beforesave(struct CtdlMessage *msg) {
                }
        } while ( (IsEmptyStr(boundary)) && (*ptr != 0) );
 
-
-       /****************** STACK SMASH IS SOMEWHERE BELOW THIS LINE **************/
-
-
-       /* Now look for the first boundary.  That is where we need to insert our fun.
+       /*
+        * Now look for the first boundary.  That is where we need to insert our fun.
         */
        if (!IsEmptyStr(boundary)) {
                snprintf(prefixed_boundary, sizeof prefixed_boundary, "--%s", boundary);
@@ -295,16 +292,15 @@ int wiki_upload_beforesave(struct CtdlMessage *msg) {
                ptr = bmstrcasestr(history_msg->cm_fields['M'], prefixed_boundary);
                if (ptr != NULL) {
                        char *the_rest_of_it = strdup(ptr);
-                       char uuid[32];
+                       char uuid[64];
                        char memo[512];
-                       char encoded_memo[768];
+                       char encoded_memo[1024];
                        generate_uuid(uuid);
                        snprintf(memo, sizeof memo, "%s|%ld|%s|%s", 
                                uuid,
                                time(NULL),
                                CCC->user.fullname,
                                config.c_nodename
-                               /* no longer logging CCC->cs_inet_email */
                        );
                        CtdlEncodeBase64(encoded_memo, memo, strlen(memo), 0);
                        sprintf(ptr, "--%s\n"
@@ -324,10 +320,9 @@ int wiki_upload_beforesave(struct CtdlMessage *msg) {
                }
 
                history_msg->cm_fields['T'] = realloc(history_msg->cm_fields['T'], 32);
-               if (history_msg->cm_fields['T'] == NULL) {
-                       syslog(LOG_EMERG, "*** REALLOC FAILED *** %s", strerror(errno));
+               if (history_msg->cm_fields['T'] != NULL) {
+                       snprintf(history_msg->cm_fields['T'], 32, "%ld", time(NULL));
                }
-               snprintf(history_msg->cm_fields['T'], 32, "%ld", time(NULL));
        
                CtdlSubmitMsg(history_msg, NULL, "", 0);
        }
@@ -335,10 +330,6 @@ int wiki_upload_beforesave(struct CtdlMessage *msg) {
                syslog(LOG_ALERT, "Empty boundary string in history message.  No history!\n");
        }
 
-
-       /****************** STACK SMASH IS SOMEWHERE BELOW THIS LINE **************/
-
-
        free(diffbuf);
        free(history_msg);
        return(0);
index 76dbacb4a028ebe476ceda0e6abab84ddf09088a..4f294cf24effc2081eb874b51f7103d9174b9953 100644 (file)
@@ -978,13 +978,9 @@ int PerformMessageHooks(struct CtdlMessage *msg, int EventType)
 
        /* Otherwise, run all the hooks appropriate to this event type.
         */
-       int num_hooks_processed = 0;
        for (fcn = MessageHookTable; fcn != NULL; fcn = fcn->next) {
                if (fcn->eventtype == EventType) {
                        total_retval = total_retval + (*fcn->h_function_pointer) (msg);
-                       syslog(LOG_DEBUG, "%d hooks completed, total_retval=%d",
-                               ++num_hooks_processed, total_retval
-                       );
                }
        }