]> code.citadel.org Git - citadel.git/blobdiff - webcit/event.c
fix various incidents reported by CLANG Static analyzer:
[citadel.git] / webcit / event.c
index 7433e53120ed2c99007772b6fa03ef64f3539344..3b6399913be85db17a0489fde41a7cd981760273 100644 (file)
@@ -2,6 +2,22 @@
  * $Id$
  *
  * Editing calendar events.
+ *
+ * Copyright (c) 1996-2010 by the citadel.org team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "webcit.h"
@@ -30,7 +46,9 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        char buf[SIZ];
        int organizer_is_me = 0;
        int i, j = 0;
+#ifdef DEBUG_UID_CALENDAR
        int sequence = 0;
+#endif
        char weekday_labels[7][32];
        char month_labels[12][32];
        long weekstart = 0;
@@ -51,7 +69,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        int which_rrend_is_preselected;
        int which_rryeartype_is_preselected;
 
-
+       const char *ch;
        char *tabnames[3];
        const char *frequency_units[8];
        const char *ordinals[6];
@@ -143,9 +161,11 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
 
        /* Learn the sequence */
        p = icalcomponent_get_first_property(vevent, ICAL_SEQUENCE_PROPERTY);
+#ifdef DEBUG_UID_CALENDAR
        if (p != NULL) {
                sequence = icalproperty_get_sequence(p);
        }
+#endif
 
        /* Begin output */
        output_headers(1, 1, 2, 0, 0, 0);
@@ -159,8 +179,10 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
 
        wc_printf("<div class=\"fix_scrollbar_bug\">");
 
+#ifdef DEBUG_UID_CALENDAR
        /************************************************************
         * Uncomment this to see the UID in calendar events for debugging
+       *************************************************************/
        wc_printf("UID == ");
        p = icalcomponent_get_first_property(vevent, ICAL_UID_PROPERTY);
        if (p != NULL) {
@@ -168,7 +190,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        }
        wc_printf("<br />\n");
        wc_printf("SEQUENCE == %d<br />\n", sequence);
-       *************************************************************/
+#endif
 
        wc_printf("<form name=\"EventForm\" method=\"POST\" action=\"save_event\">\n");
        wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
@@ -451,11 +473,12 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY);
            attendee != NULL;
            attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
-               strcpy(attendee_string, icalproperty_get_attendee(attendee));
-               if (!strncasecmp(attendee_string, "MAILTO:", 7)) {
+
+               ch = icalproperty_get_attendee(attendee);
+               if ((ch != NULL) && !strncasecmp(ch, "MAILTO:", 7)) {
 
                        /* screen name or email address */
-                       strcpy(attendee_string, &attendee_string[7]);
+                       safestrncpy(attendee_string, ch + 7, sizeof(attendee_string));
                        striplt(attendee_string);
                        if (i++) wc_printf("\n");
                        escputs(attendee_string);
@@ -795,6 +818,7 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
        char organizer_string[SIZ];
        int sequence = 0;
        enum icalproperty_transp formtransp = ICAL_TRANSP_NONE;
+       const char *ch;
 
        if (supplied_vevent != NULL) {
                vevent = supplied_vevent;
@@ -961,7 +985,7 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
                                                if (YESBSTR(buf)) recur.by_day[j++] =
                                                        icalrecurrencetype_day_day_of_week(i+1);
                                        }
-                                       recur.by_day[j++] = ICAL_RECURRENCE_ARRAY_MAX;
+                                       recur.by_day[j] = ICAL_RECURRENCE_ARRAY_MAX;
                                        break;
 
                                case ICAL_MONTHLY_RECURRENCE:
@@ -1089,15 +1113,15 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
                                foundit = 0;
 
                                for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY); attendee != NULL; attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
-                                       if (!strcasecmp(attendee_string,
-                                          icalproperty_get_attendee(attendee)))
+                                       ch = icalproperty_get_attendee(attendee);
+                                       if ((ch != NULL) && !strcasecmp(attendee_string, ch))
                                                ++foundit;
                                }
 
 
                                if (foundit == 0) {
                                        icalcomponent_add_property(vevent,
-                                               icalproperty_new_attendee(attendee_string)
+                                                                  icalproperty_new_attendee(attendee_string)
                                        );
                                }
                        }
@@ -1107,9 +1131,9 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
                 * Remove any attendees *not* listed in the web form
                 */
 STARTOVER:     for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY); attendee != NULL; attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
-                       strcpy(attendee_string, icalproperty_get_attendee(attendee));
-                       if (!strncasecmp(attendee_string, "MAILTO:", 7)) {
-                               strcpy(attendee_string, &attendee_string[7]);
+                       ch = icalproperty_get_attendee(attendee);
+                       if ((ch != NULL) && !strncasecmp(ch, "MAILTO:", 7)) {
+                               safestrncpy(attendee_string, ch + 7, sizeof(attendee_string));
                                striplt(attendee_string);
                                foundit = 0;
                                for (i=0; i<num_tokens(form_attendees, '\n'); ++i) {
@@ -1196,7 +1220,7 @@ STARTOVER:        for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDE
                        summary();
                }
                else {
-                       readloop(readfwd);
+                       readloop(readfwd, eUseDefault);
                }
        }
 }