/*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2001-2012 Match Grun and the Claws Mail team
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2001-2015 Match Grun and the Claws Mail 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
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
*/
/*
static const gchar *charset = NULL;
if (charset == NULL)
- charset = getenv("PILOT_CHARSET");
+ charset = g_getenv("PILOT_CHARSET");
if (charset == NULL)
charset = CS_CP1252;
*/
static gboolean jpilot_mark_files( JPilotFile *pilotFile ) {
gboolean retVal = FALSE;
- struct stat filestat;
+ GStatBuf filestat;
gchar *pcFile;
/* Mark PDB file cache */
*/
static gboolean jpilot_check_files( JPilotFile *pilotFile ) {
gboolean retVal = TRUE;
- struct stat filestat;
+ GStatBuf filestat;
gchar *pcFile;
/* Check main file */
return MGU_ERROR_READ;
}
- fseek(in, dbh.app_info_offset, SEEK_SET);
+ if (fseek(in, dbh.app_info_offset, SEEK_SET) < 0) {
+ fclose(in);
+ return MGU_ERROR_READ;
+ }
*buf = ( char * ) malloc(rec_size);
if (!(*buf)) {
fclose(in);
}
memcpy(packed_header, &l, sizeof(l));
len=ntohl(l);
- if (len > 255) {
+ if (len > 255 || len < sizeof(l)) {
return -1;
}
num = fread(packed_header+sizeof(l), len-sizeof(l), 1, pc_in);
}
if( feof( in ) ) {
fclose( in );
+ if (mem_rh)
+ free_mem_rec_header( &mem_rh );
return MGU_EOF;
}
}
unique_id = mem_rh->unique_id;
}
}
- fseek( in, next_offset, SEEK_SET );
+ if (fseek( in, next_offset, SEEK_SET ) < 0) {
+ free_mem_rec_header( &mem_rh );
+ fclose(in);
+ return MGU_ERROR_READ;
+ }
while( ! feof( in ) ) {
fpos = ftell( in );
if( out_of_order ) {
if( labelEntry ) {
*buffer = '\0';
- strcpy( buffer, labelEntry );
+ g_strlcpy( buffer, labelEntry, sizeof(buffer) );
node = list = jpilot_parse_email( buffer );
while( node ) {
email = addritem_create_item_email();
}
if( person->listEMail ) {
- if( cat_id > -1 && cat_id < JPILOT_NUM_CATEG ) {
- /* Add to specified category */
- addrcache_folder_add_person(
- pilotFile->addressCache,
- folderInd[cat_id], person );
- }
- else {
- /* Add to root folder */
- addrcache_add_person(
- pilotFile->addressCache, person );
- }
+ /* Add to specified category */
+ addrcache_folder_add_person(
+ pilotFile->addressCache,
+ folderInd[cat_id], person );
}
else {
addritem_free_item_person( person );
for( i = 0; i < NUM_CUSTOM_LABEL; i++ ) {
gchar *labelName = ai->labels[i+IND_CUSTOM_LABEL];
if( labelName ) {
- g_strchomp( labelName );
- g_strchug( labelName );
+ g_strstrip( labelName );
if( *labelName != '\0' ) {
if( convert_charcode ) {
gchar *convertBuff = NULL;
cur_locale = conv_get_current_locale();
- if( g_ascii_strncasecmp( cur_locale, "ja", 2 ) == 0 ) {
+ if( g_ascii_strncasecmp( cur_locale, "hu", 2 ) == 0 ||
+ g_ascii_strncasecmp( cur_locale, "ja", 2 ) == 0 ||
+ g_ascii_strncasecmp( cur_locale, "ko", 2 ) == 0 ||
+ g_ascii_strncasecmp( cur_locale, "vi", 2 ) == 0 ||
+ g_ascii_strncasecmp( cur_locale, "zh", 2 ) == 0 ) {
name_order = FAMILY_FIRST;
}
homedir = get_home_dir();
if( ! homedir ) return g_strdup( "" );
- strcpy( str, homedir );
+ g_strlcpy( str, homedir , sizeof(str));
len = strlen( str );
if( len > 0 ) {
if( str[ len-1 ] != G_DIR_SEPARATOR ) {