diff --git a/calendar/libical/src/libical/icalderivedvalue.c.in b/calendar/libical/src/libical/icalderivedvalue.c.in index 0d2178041fcc..c1debf408247 100644 --- a/calendar/libical/src/libical/icalderivedvalue.c.in +++ b/calendar/libical/src/libical/icalderivedvalue.c.in @@ -3,7 +3,7 @@ FILE: icalvalue.c CREATOR: eric 02 May 1999 - $Id: icalderivedvalue.c.in,v 1.11 2002/06/27 00:22:09 acampi Exp $ + $Id: icalderivedvalue.c.in,v 1.13 2005/01/24 11:48:01 acampi Exp $ (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org @@ -39,13 +39,8 @@ #include "icalvalueimpl.h" #include /* for malloc */ -#include /* for sprintf */ #include /* For memset, others */ -#include /* For offsetof() macro */ #include -#include /* for mktime */ -#include /* for atoi and atof */ -#include /* for SHRT_MAX */ struct icalvalue_impl* icalvalue_new_impl(icalvalue_kind kind); diff --git a/calendar/libical/src/libical/icalduration.c b/calendar/libical/src/libical/icalduration.c index c8bcd90f058b..50749259fd6f 100644 --- a/calendar/libical/src/libical/icalduration.c +++ b/calendar/libical/src/libical/icalduration.c @@ -3,7 +3,7 @@ FILE: icaltime.c CREATOR: eric 02 June 2000 - $Id: icalduration.c,v 1.16 2002/10/30 21:22:03 acampi Exp $ + $Id: icalduration.c,v 1.18 2005/01/24 11:50:54 acampi Exp $ $Locker: $ (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org @@ -183,14 +183,13 @@ struct icaldurationtype icaldurationtype_from_string(const char* str) return icaldurationtype_bad_duration(); } -#define TMP_BUF_SIZE 1024 static void append_duration_segment(char** buf, char** buf_ptr, size_t* buf_size, char* sep, unsigned int value) { - char temp[TMP_BUF_SIZE]; + char temp[32]; - sprintf(temp,"%d",value); + snprintf(temp,sizeof(temp),"%d",value); icalmemory_append_string(buf, buf_ptr, buf_size, temp); icalmemory_append_string(buf, buf_ptr, buf_size, sep); diff --git a/calendar/libical/src/libical/icalmime.c b/calendar/libical/src/libical/icalmime.c index 672ae77870b1..b3da67ae3ec0 100644 --- a/calendar/libical/src/libical/icalmime.c +++ b/calendar/libical/src/libical/icalmime.c @@ -4,7 +4,7 @@ CREATOR: eric 26 July 2000 - $Id: icalmime.c,v 1.7 2003/05/09 14:30:06 acampi Exp $ + $Id: icalmime.c,v 1.8 2005/01/24 12:49:11 acampi Exp $ $Locker: $ (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org @@ -199,7 +199,7 @@ icalcomponent* icalmime_parse(char* (*get_string)(char *s, size_t size, minor = parts[i].header.minor_text; } - sprintf(mimetype,"%s/%s",major,minor); + snprintf(mimetype,sizeof(mimetype),"%s/%s",major,minor); comp = icalcomponent_new(ICAL_XLICMIMEPART_COMPONENT); diff --git a/calendar/libical/src/libical/icaltime.h b/calendar/libical/src/libical/icaltime.h index efb450b84e90..f61815f2f3da 100644 --- a/calendar/libical/src/libical/icaltime.h +++ b/calendar/libical/src/libical/icaltime.h @@ -4,7 +4,7 @@ CREATOR: eric 02 June 2000 - $Id: icaltime.h,v 1.24 2003/02/17 14:23:17 acampi Exp $ + $Id: icaltime.h,v 1.25 2005/01/24 13:06:10 acampi Exp $ $Locker: $ (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org @@ -204,6 +204,10 @@ int icaltime_day_of_week(const struct icaltimetype t); given time is within. */ int icaltime_start_doy_of_week(const struct icaltimetype t); +/** Return the day of the year for the first day of the week that the + given time is within. */ +int icaltime_start_doy_in_week(const struct icaltimetype t, int fdow); + /** Return the day of the year for the first day of the week that the given time is within. */ int icaltime_start_doy_week(const struct icaltimetype t, int fdow); diff --git a/calendar/libical/src/libical/icalvalue.c b/calendar/libical/src/libical/icalvalue.c index 12a811b509ae..b8c5150403bf 100644 --- a/calendar/libical/src/libical/icalvalue.c +++ b/calendar/libical/src/libical/icalvalue.c @@ -4,7 +4,7 @@ FILE: icalvalue.c CREATOR: eric 02 May 1999 - $Id: icalvalue.c,v 1.37 2003/01/16 01:14:21 acampi Exp $ + $Id: icalvalue.c,v 1.40 2005/01/24 13:11:31 acampi Exp $ (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org @@ -39,7 +39,7 @@ #include "icalvalueimpl.h" #include /* for malloc */ -#include /* for sprintf */ +#include /* for snprintf */ #include /* For memset, others */ #include /* For offsetof() macro */ #include @@ -321,7 +321,7 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char* if (error != 0){ char temp[TMP_BUF_SIZE]; - sprintf(temp,"%s Values are not implemented", + snprintf(temp,sizeof(temp),"%s Values are not implemented", icalvalue_kind_to_string(kind)); *error = icalproperty_vanew_xlicerror( temp, @@ -416,10 +416,8 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char* /* HACK */ if (error != 0){ - char temp[TMP_BUF_SIZE]; - sprintf(temp,"GEO Values are not implemented"); *error = icalproperty_vanew_xlicerror( - temp, + "GEO Values are not implemented", icalparameter_new_xlicerrortype( ICAL_XLICERRORTYPE_VALUEPARSEERROR), 0); @@ -646,8 +644,8 @@ static char* icalvalue_binary_as_ical_string(const icalvalue* value) { data = icalvalue_get_binary(value); - str = (char*)icalmemory_tmp_buffer(60); - sprintf(str,"icalvalue_binary_as_ical_string is not implemented yet"); + str = icalmemory_tmp_copy( + "icalvalue_binary_as_ical_string is not implemented yet"); return str; } @@ -689,9 +687,9 @@ static char* icalvalue_utcoffset_as_ical_string(const icalvalue* value) s = (data - (h*3600) - (m*60)); if (s > 0) - sprintf(str,"%c%02d%02d%02d",sign,abs(h),abs(m),abs(s)); + snprintf(str,9,"%c%02d%02d%02d",sign,abs(h),abs(m),abs(s)); else - sprintf(str,"%c%02d%02d",sign,abs(h),abs(m)); + snprintf(str,9,"%c%02d%02d",sign,abs(h),abs(m)); return str; } @@ -831,9 +829,9 @@ void print_time_to_string(char* str, const struct icaltimetype *data) char temp[20]; if (icaltime_is_utc(*data)){ - sprintf(temp,"%02d%02d%02dZ",data->hour,data->minute,data->second); + snprintf(temp,sizeof(temp),"%02d%02d%02dZ",data->hour,data->minute,data->second); } else { - sprintf(temp,"%02d%02d%02d",data->hour,data->minute,data->second); + snprintf(temp,sizeof(temp),"%02d%02d%02d",data->hour,data->minute,data->second); } strcat(str,temp); @@ -844,7 +842,7 @@ void print_date_to_string(char* str, const struct icaltimetype *data) { char temp[20]; - sprintf(temp,"%04d%02d%02d",data->year,data->month,data->day); + snprintf(temp,sizeof(temp),"%04d%02d%02d",data->year,data->month,data->day); strcat(str,temp); } @@ -898,6 +896,8 @@ static const char* icalvalue_datetime_as_ical_string(const icalvalue* value) { } +#define MAX_FLOAT_DIGITS 40 + static char* icalvalue_float_as_ical_string(const icalvalue* value) { float data; @@ -905,13 +905,15 @@ static char* icalvalue_float_as_ical_string(const icalvalue* value) { icalerror_check_arg_rz( (value!=0),"value"); data = icalvalue_get_float(value); - str = (char*)icalmemory_tmp_buffer(15); + str = (char*)icalmemory_tmp_buffer(MAX_FLOAT_DIGITS); - sprintf(str,"%f",data); + snprintf(str,MAX_FLOAT_DIGITS,"%f",data); return str; } +#define MAX_GEO_DIGITS 40 + static char* icalvalue_geo_as_ical_string(const icalvalue* value) { struct icalgeotype data; @@ -920,9 +922,9 @@ static char* icalvalue_geo_as_ical_string(const icalvalue* value) { data = icalvalue_get_geo(value); - str = (char*)icalmemory_tmp_buffer(25); + str = (char*)icalmemory_tmp_buffer(MAX_GEO_DIGITS); - sprintf(str,"%f;%f",data.lat,data.lon); + snprintf(str,MAX_GEO_DIGITS,"%f;%f",data.lat,data.lon); return str; } diff --git a/calendar/libical/src/libical/sspm.c b/calendar/libical/src/libical/sspm.c index ffc7f7eb03f5..77ad70525694 100644 --- a/calendar/libical/src/libical/sspm.c +++ b/calendar/libical/src/libical/sspm.c @@ -3,7 +3,7 @@ FILE: sspm.c Parse Mime CREATOR: eric 25 June 2000 - $Id: sspm.c,v 1.8 2003/11/17 22:51:53 gray-john Exp $ + $Id: sspm.c,v 1.9 2005/01/24 13:15:19 acampi Exp $ $Locker: $ The contents of this file are subject to the Mozilla Public License @@ -1250,9 +1250,9 @@ void sspm_write_part(struct sspm_buffer *buf,struct sspm_part *part, int *part_n void sspm_append_hex(struct sspm_buffer* buf, char ch) { - char tmp[3]; + char tmp[4]; - sprintf(tmp,"=%02X",ch); + snprintf(tmp,sizeof(tmp),"=%02X",ch); sspm_append_string(buf,tmp); } @@ -1481,19 +1481,19 @@ void sspm_write_header(struct sspm_buffer *buf,struct sspm_header *header) minor = header->minor_text; } - sprintf(temp,"Content-Type: %s/%s",major,minor); + snprintf(temp,sizeof(temp),"Content-Type: %s/%s",major,minor); sspm_append_string(buf,temp); if(header->boundary != 0){ - sprintf(temp,";boundary=\"%s\"",header->boundary); + snprintf(temp,sizeof(temp),";boundary=\"%s\"",header->boundary); sspm_append_string(buf,temp); } /* Append any content type parameters */ if(header->content_type_params != 0){ for(i=0; *(header->content_type_params[i])!= 0;i++){ - sprintf(temp,header->content_type_params[i]); + snprintf(temp,sizeof(temp),header->content_type_params[i]); sspm_append_char(buf,';'); sspm_append_string(buf,temp); } @@ -1505,7 +1505,7 @@ void sspm_write_header(struct sspm_buffer *buf,struct sspm_header *header) if(header->encoding != SSPM_UNKNOWN_ENCODING && header->encoding != SSPM_NO_ENCODING){ - sprintf(temp,"Content-Transfer-Encoding: %s\n", + snprintf(temp,sizeof(temp),"Content-Transfer-Encoding: %s\n", sspm_encoding_string(header->encoding)); } diff --git a/calendar/libical/src/libicalss/icaldirset.c b/calendar/libical/src/libicalss/icaldirset.c index d3114c2e1281..2f321788e5d2 100644 --- a/calendar/libical/src/libicalss/icaldirset.c +++ b/calendar/libical/src/libicalss/icaldirset.c @@ -3,7 +3,7 @@ FILE: icaldirset.c CREATOR: eric 28 November 1999 - $Id: icaldirset.c,v 1.21 2004/05/10 23:06:35 acampi Exp $ + $Id: icaldirset.c,v 1.22 2005/01/24 14:00:39 acampi Exp $ $Locker: $ (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org @@ -315,7 +315,7 @@ int icaldirset_next_uid_number(icaldirset* dset) icalerror_check_arg_rz( (dset!=0), "dset"); - sprintf(filename,"%s/%s",dset->dir,"SEQUENCE"); + snprintf(filename,sizeof(filename),"%s/%s",dset->dir,"SEQUENCE"); /* Create the file if it does not exist.*/ if (stat(filename,&sbuf) == -1 || !S_ISREG(sbuf.st_mode)){ @@ -374,7 +374,7 @@ icalerrorenum icaldirset_next_cluster(icaldirset* dset) return ICAL_NO_ERROR; } - sprintf(path,"%s/%s", dset->dir,(char*)pvl_data(dset->directory_iterator)); + snprintf(path,sizeof(path),"%s/%s", dset->dir,(char*)pvl_data(dset->directory_iterator)); icalcluster_free(dset->cluster); dset->cluster = icalfileset_produce_icalcluster(path); @@ -399,9 +399,9 @@ static void icaldirset_add_uid(icalcomponent* comp) #ifndef WIN32 uname(&unamebuf); - sprintf(uidstring,"%d-%s",(int)getpid(),unamebuf.nodename); + snprintf(uidstring,sizeof(uidstring),"%d-%s",(int)getpid(),unamebuf.nodename); #else - sprintf(uidstring,"%d-%s",(int)getpid(),"WINDOWS"); /* FIX: There must be an easy get the system name */ + snprintf(uidstring,sizeof(uidstring),"%d-%s",(int)getpid(),"WINDOWS"); /* FIX: There must be an easy get the system name */ #endif uid = icalproperty_new_uid(uidstring); diff --git a/calendar/libical/src/libicalss/icalmessage.c b/calendar/libical/src/libicalss/icalmessage.c index e81132753cab..83c149a56838 100644 --- a/calendar/libical/src/libicalss/icalmessage.c +++ b/calendar/libical/src/libicalss/icalmessage.c @@ -3,7 +3,7 @@ FILE: icalmessage.c CREATOR: ebusboom 07 Nov 2000 - $Id: icalmessage.c,v 1.5 2002/06/27 02:30:59 acampi Exp $ + $Id: icalmessage.c,v 1.7 2005/01/24 14:02:20 acampi Exp $ $Locker: $ (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org @@ -115,7 +115,7 @@ icalcomponent *icalmessage_new_reply_base(icalcomponent* c, const char* msg) { icalproperty *attendee; - char tmp[45]; + char tmp[1024]; icalcomponent *reply = icalcomponent_vanew( ICAL_VCALENDAR_COMPONENT, @@ -159,10 +159,10 @@ icalcomponent *icalmessage_new_reply_base(icalcomponent* c, icalcomponent_add_property(reply,icalproperty_new_version("2.0")); #ifndef WIN32 - sprintf(tmp, + snprintf(tmp,sizeof(tmp), "-//SoftwareStudio//NONSGML %s %s //EN",PACKAGE,VERSION); #else - sprintf(tmp, + snprintf(tmp,sizeof(tmp), "-//SoftwareStudio//NONSGML %s %s //EN",ICAL_PACKAGE,ICAL_VERSION); #endif icalcomponent_add_property(reply,icalproperty_new_prodid(tmp));