+2008-11-26 [colin] 3.6.1cvs43
+
+ * src/imap.c
+ * src/news.c
+ * src/etpan/imap-thread.c
+ Fix possible crashes due to clist_begin()
+ not checking for NULLs (it should!)
+
2008-11-25 [colin] 3.6.1cvs42
* src/procmime.c
( cvs diff -u -r 1.382.2.486 -r 1.382.2.487 src/compose.c; cvs diff -u -r 1.49.2.120 -r 1.49.2.121 src/procmime.c; ) > 3.6.1cvs40.patchset
( cvs diff -u -r 1.382.2.487 -r 1.382.2.488 src/compose.c; ) > 3.6.1cvs41.patchset
( cvs diff -u -r 1.49.2.121 -r 1.49.2.122 src/procmime.c; ) > 3.6.1cvs42.patchset
+( cvs diff -u -r 1.179.2.236 -r 1.179.2.237 src/imap.c; cvs diff -u -r 1.101.2.57 -r 1.101.2.58 src/news.c; cvs diff -u -r 1.1.4.105 -r 1.1.4.106 src/etpan/imap-thread.c; ) > 3.6.1cvs43.patchset
MICRO_VERSION=1
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=42
+EXTRA_VERSION=43
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
if (imap->imap_selection_info->sel_perm_flags) {
GSList *t_flags = NULL;
- clistiter *cur =
- clist_begin(imap->imap_selection_info->sel_perm_flags);
+ clistiter *cur = NULL;
+ if (imap->imap_selection_info->sel_perm_flags)
+ cur = clist_begin(imap->imap_selection_info->sel_perm_flags);
+
for (; cur; cur = clist_next(cur)) {
struct mailimap_flag_perm *flag = (struct mailimap_flag_perm *)clist_content(cur);
if (flag->fl_type == MAILIMAP_FLAG_PERM_ALL)
static int
result_to_uid_list(clist * fetch_result, carray ** result)
{
- clistiter * cur;
+ clistiter * cur = NULL;
int r;
int res;
carray * tab;
goto err;
}
- for(cur = clist_begin(fetch_result) ; cur != NULL ;
- cur = clist_next(cur)) {
+ if (fetch_result)
+ cur = clist_begin(fetch_result);
+
+ for(; cur != NULL ; cur = clist_next(cur)) {
struct mailimap_msg_att * msg_att;
uint32_t uid;
uint32_t * puid;
static int
result_to_uid_flags_list(clist * fetch_result, carray ** result)
{
- clistiter * cur;
+ clistiter * cur = NULL;
int r;
int res;
carray * tab;
res = MAILIMAP_ERROR_MEMORY;
goto err;
}
-
- for(cur = clist_begin(fetch_result) ; cur != NULL ;
- cur = clist_next(cur)) {
+
+ if (fetch_result)
+ cur = clist_begin(fetch_result);
+
+ for(; cur != NULL ; cur = clist_next(cur)) {
struct mailimap_msg_att * msg_att;
uint32_t uid;
uint32_t * puid;
return r;
}
- if (clist_begin(fetch_result) == NULL) {
+ if (fetch_result == NULL || clist_begin(fetch_result) == NULL) {
mailimap_fetch_list_free(fetch_result);
return MAILIMAP_ERROR_FETCH;
}
text = NULL;
text_length = 0;
- for(cur = clist_begin(msg_att->att_list) ; cur != NULL ;
- cur = clist_next(cur)) {
+ if (msg_att->att_list)
+ cur = clist_begin(msg_att->att_list);
+ else
+ cur = NULL;
+
+ for(; cur != NULL ; cur = clist_next(cur)) {
msg_att_item = clist_content(cur);
if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) {
return r;
}
- if (clist_begin(fetch_result) == NULL) {
+ if (fetch_result == NULL || clist_begin(fetch_result) == NULL) {
mailimap_fetch_list_free(fetch_result);
return MAILIMAP_ERROR_FETCH;
}
text = NULL;
text_length = 0;
- for(cur = clist_begin(msg_att->att_list) ; cur != NULL ;
- cur = clist_next(cur)) {
+ if (msg_att->att_list)
+ cur = clist_begin(msg_att->att_list);
+ else
+ cur = NULL;
+
+ for(; cur != NULL ; cur = clist_next(cur)) {
msg_att_item = clist_content(cur);
if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) {
ref_size = 0;
att_dyn = NULL;
- for(item_cur = clist_begin(msg_att->att_list) ; item_cur != NULL ;
- item_cur = clist_next(item_cur)) {
+ if (msg_att->att_list)
+ item_cur = clist_begin(msg_att->att_list);
+ else
+ item_cur = NULL;
+ for(; item_cur != NULL ; item_cur = clist_next(item_cur)) {
struct mailimap_msg_att_item * item;
item = clist_content(item_cur);
i = 0;
env_list = carray_new(16);
- for(cur = clist_begin(fetch_result) ; cur != NULL ;
- cur = clist_next(cur)) {
- struct mailimap_msg_att * msg_att;
- struct imap_fetch_env_info * env_info;
- GSList *tags = NULL;
-
- msg_att = clist_content(cur);
-
- env_info = fetch_to_env_info(msg_att, &tags);
- if (!env_info)
- return MAILIMAP_ERROR_MEMORY;
- carray_add(env_list, env_info, NULL);
- carray_add(env_list, tags, NULL);
+ if (fetch_result) {
+ for(cur = clist_begin(fetch_result) ; cur != NULL ;
+ cur = clist_next(cur)) {
+ struct mailimap_msg_att * msg_att;
+ struct imap_fetch_env_info * env_info;
+ GSList *tags = NULL;
+
+ msg_att = clist_content(cur);
+
+ env_info = fetch_to_env_info(msg_att, &tags);
+ if (!env_info)
+ return MAILIMAP_ERROR_MEMORY;
+ carray_add(env_list, env_info, NULL);
+ carray_add(env_list, tags, NULL);
+ }
+ * p_env_list = env_list;
+ } else {
+ * p_env_list = NULL;
}
-
- * p_env_list = env_list;
-
+
return MAIL_NO_ERROR;
}
return r;
}
- if (clist_begin(fetch_result) == NULL) {
+ if (fetch_result == NULL || clist_begin(fetch_result) == NULL) {
res = MAILIMAP_ERROR_FETCH;
debug_print("clist_begin = NULL\n");
goto err;
return result;
}
- if (capabilities == NULL) {
+ if (capabilities == NULL || capabilities->cap_list == NULL) {
return MAILIMAP_NO_ERROR;
}
int start, end, t;
GSList *cur;
+ if (!set || !set->set_list)
+ return NULL;
+
for (list = clist_begin(set->set_list); list; list = clist_next(list)) {
struct mailimap_set_item *item = (struct mailimap_set_item *)clist_content(list);
start = item->set_first;
return '\0';
}
- if (clist_count(lep_list) > 0) {
+ if (lep_list != NULL && clist_count(lep_list) > 0) {
clistiter * iter = clist_begin(lep_list);
struct mailimap_mailbox_list * mb;
mb = clist_content(iter);
for(cur = seq_list ; cur != NULL ; cur = g_slist_next(cur)) {
struct mailimap_set * imapset = (struct mailimap_set *)cur->data;
- struct mailimap_set_item *set_item = clist_content(
- clist_begin(imapset->set_list));
+ struct mailimap_set_item *set_item = NULL;
+
+ if (imapset->set_list)
+ set_item = clist_content(clist_begin(imapset->set_list));
+ else
+ continue;
statusbar_progress_all(set_item->set_first, total, 1);
}
got_values = 0;
- for(iter = clist_begin(data_status->st_info_list) ; iter != NULL ;
- iter = clist_next(iter)) {
- struct mailimap_status_info * info;
-
- info = clist_content(iter);
- switch (info->st_att) {
- case MAILIMAP_STATUS_ATT_MESSAGES:
- if (messages) {
- * messages = info->st_value;
- got_values |= 1 << 0;
- }
- break;
-
- case MAILIMAP_STATUS_ATT_UIDNEXT:
- if (uid_next) {
- * uid_next = info->st_value;
- got_values |= 1 << 2;
- }
- break;
-
- case MAILIMAP_STATUS_ATT_UIDVALIDITY:
- if (uid_validity) {
- * uid_validity = info->st_value;
- got_values |= 1 << 3;
- }
- break;
-
- case MAILIMAP_STATUS_ATT_UNSEEN:
- if (unseen) {
- * unseen = info->st_value;
- got_values |= 1 << 4;
+ if (data_status->st_info_list) {
+ for(iter = clist_begin(data_status->st_info_list) ; iter != NULL ;
+ iter = clist_next(iter)) {
+ struct mailimap_status_info * info;
+
+ info = clist_content(iter);
+ switch (info->st_att) {
+ case MAILIMAP_STATUS_ATT_MESSAGES:
+ if (messages) {
+ * messages = info->st_value;
+ got_values |= 1 << 0;
+ }
+ break;
+
+ case MAILIMAP_STATUS_ATT_UIDNEXT:
+ if (uid_next) {
+ * uid_next = info->st_value;
+ got_values |= 1 << 2;
+ }
+ break;
+
+ case MAILIMAP_STATUS_ATT_UIDVALIDITY:
+ if (uid_validity) {
+ * uid_validity = info->st_value;
+ got_values |= 1 << 3;
+ }
+ break;
+
+ case MAILIMAP_STATUS_ATT_UNSEEN:
+ if (unseen) {
+ * unseen = info->st_value;
+ got_values |= 1 << 4;
+ }
+ break;
}
- break;
}
}
mailimap_mailbox_data_status_free(data_status);
}
}
- for(cur = clist_begin(imap_flags->mbf_oflags) ; cur != NULL ;
- cur = clist_next(cur)) {
- struct mailimap_mbx_list_oflag * oflag;
-
- oflag = clist_content(cur);
-
- switch (oflag->of_type) {
- case MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS:
- flags |= ETPAN_IMAP_MB_NOINFERIORS;
- break;
+ if (imap_flags->mbf_oflags) {
+ for(cur = clist_begin(imap_flags->mbf_oflags) ; cur != NULL ;
+ cur = clist_next(cur)) {
+ struct mailimap_mbx_list_oflag * oflag;
+
+ oflag = clist_content(cur);
+
+ switch (oflag->of_type) {
+ case MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS:
+ flags |= ETPAN_IMAP_MB_NOINFERIORS;
+ break;
+ }
}
- }
-
+ }
return flags;
}
clistiter * iter;
GSList * item_list = NULL, *llast = NULL;
- for(iter = clist_begin(list) ; iter != NULL ;
- iter = clist_next(iter)) {
- struct mailimap_mailbox_list * mb;
- int flags;
- char delimiter;
- char * name;
- char * dup_name;
- gchar * base;
- gchar * loc_name;
- gchar * loc_path;
- FolderItem *new_item;
-
- mb = clist_content(iter);
+ if (list) {
+ for(iter = clist_begin(list) ; iter != NULL ;
+ iter = clist_next(iter)) {
+ struct mailimap_mailbox_list * mb;
+ int flags;
+ char delimiter;
+ char * name;
+ char * dup_name;
+ gchar * base;
+ gchar * loc_name;
+ gchar * loc_path;
+ FolderItem *new_item;
+
+ mb = clist_content(iter);
+
+ if (mb == NULL)
+ continue;
- if (mb == NULL)
- continue;
+ flags = 0;
+ if (mb->mb_flag != NULL)
+ flags = imap_flags_to_flags(mb->mb_flag);
- flags = 0;
- if (mb->mb_flag != NULL)
- flags = imap_flags_to_flags(mb->mb_flag);
-
- delimiter = mb->mb_delimiter;
- name = mb->mb_name;
-
- dup_name = strdup(name);
- if (delimiter != '\0')
- subst_char(dup_name, delimiter, '/');
-
- base = g_path_get_basename(dup_name);
- if (base[0] == '.') {
- g_free(base);
- free(dup_name);
- continue;
- }
- if (!all && path_cmp(name, real_path) == 0) {
+ delimiter = mb->mb_delimiter;
+ name = mb->mb_name;
+
+ dup_name = strdup(name);
+ if (delimiter != '\0')
+ subst_char(dup_name, delimiter, '/');
+
+ base = g_path_get_basename(dup_name);
+ if (base[0] == '.') {
+ g_free(base);
+ free(dup_name);
+ continue;
+ }
+ if (!all && path_cmp(name, real_path) == 0) {
+ g_free(base);
+ free(dup_name);
+ continue;
+ }
+
+ if (!all && dup_name[strlen(dup_name)-1] == '/') {
+ dup_name[strlen(dup_name)-1] = '\0';
+ }
+
+ loc_name = imap_modified_utf7_to_utf8(base, FALSE);
+ loc_path = imap_modified_utf7_to_utf8(dup_name, FALSE);
+
+ new_item = folder_item_new(FOLDER(folder), loc_name, loc_path);
+ if ((flags & ETPAN_IMAP_MB_NOINFERIORS) != 0)
+ new_item->no_sub = TRUE;
+ if (strcmp(dup_name, "INBOX") != 0 &&
+ ((flags & ETPAN_IMAP_MB_NOSELECT) != 0))
+ new_item->no_select = TRUE;
+
+ if (item_list == NULL)
+ llast = item_list = g_slist_append(item_list, new_item);
+ else {
+ llast = g_slist_append(llast, new_item);
+ llast = llast->next;
+ }
+ debug_print("folder '%s' found.\n", loc_path);
g_free(base);
- free(dup_name);
- continue;
- }
+ g_free(loc_path);
+ g_free(loc_name);
- if (!all && dup_name[strlen(dup_name)-1] == '/') {
- dup_name[strlen(dup_name)-1] = '\0';
- }
-
- loc_name = imap_modified_utf7_to_utf8(base, FALSE);
- loc_path = imap_modified_utf7_to_utf8(dup_name, FALSE);
-
- new_item = folder_item_new(FOLDER(folder), loc_name, loc_path);
- if ((flags & ETPAN_IMAP_MB_NOINFERIORS) != 0)
- new_item->no_sub = TRUE;
- if (strcmp(dup_name, "INBOX") != 0 &&
- ((flags & ETPAN_IMAP_MB_NOSELECT) != 0))
- new_item->no_select = TRUE;
-
- if (item_list == NULL)
- llast = item_list = g_slist_append(item_list, new_item);
- else {
- llast = g_slist_append(llast, new_item);
- llast = llast->next;
+ free(dup_name);
}
- debug_print("folder '%s' found.\n", loc_path);
- g_free(base);
- g_free(loc_path);
- g_free(loc_name);
-
- free(dup_name);
- }
-
+ }
return item_list;
}
result = NULL;
- for(iter = clist_begin(list) ; iter != NULL ;
- iter = clist_next(iter)) {
- uint32_t * puid;
-
- puid = clist_content(iter);
- result = g_slist_prepend(result, GINT_TO_POINTER(* puid));
- }
-
- result = g_slist_reverse(result);
+ if (list) {
+ for(iter = clist_begin(list) ; iter != NULL ;
+ iter = clist_next(iter)) {
+ uint32_t * puid;
+
+ puid = clist_content(iter);
+ result = g_slist_prepend(result, GINT_TO_POINTER(* puid));
+ }
+ result = g_slist_reverse(result);
+ }
return result;
}
return NULL;
}
- for (cur = clist_begin(grouplist); cur; cur = clist_next(cur)) {
- struct newsnntp_group_info *info = (struct newsnntp_group_info *)
- clist_content(cur);
- if (fprintf(fp, "%s %d %d %c\n",
- info->grp_name,
- info->grp_last,
- info->grp_first,
- info->grp_type) < 0) {
- log_error(LOG_PROTOCOL, ("Can't write newsgroup list\n"));
- session_destroy(SESSION(session));
- REMOTE_FOLDER(folder)->session = NULL;
- fclose(fp);
- g_free(filename);
- newsnntp_list_free(grouplist);
- return NULL;
+ if (grouplist) {
+ for (cur = clist_begin(grouplist); cur; cur = clist_next(cur)) {
+ struct newsnntp_group_info *info = (struct newsnntp_group_info *)
+ clist_content(cur);
+ if (fprintf(fp, "%s %d %d %c\n",
+ info->grp_name,
+ info->grp_last,
+ info->grp_first,
+ info->grp_type) < 0) {
+ log_error(LOG_PROTOCOL, ("Can't write newsgroup list\n"));
+ session_destroy(SESSION(session));
+ REMOTE_FOLDER(folder)->session = NULL;
+ fclose(fp);
+ g_free(filename);
+ newsnntp_list_free(grouplist);
+ return NULL;
+ }
}
+ newsnntp_list_free(grouplist);
}
- newsnntp_list_free(grouplist);
-
if (fclose(fp) == EOF) {
log_error(LOG_PROTOCOL, ("Can't write newsgroup list\n"));
session_destroy(SESSION(session));
{
struct newsnntp_xhdr_resp_item *hdr;
+ if (!hdrlist)
+ return NULL;
+
hdr = clist_content(clist_begin(hdrlist));
if (hdr->hdr_article != msginfo->msgnum)
return NULL;
return NULL;
}
- for (cur = clist_begin(msglist); cur; cur = clist_next(cur)) {
- struct newsnntp_xover_resp_item *ritem = (struct newsnntp_xover_resp_item *)clist_content(cur);
- msginfo = news_parse_xover(ritem);
-
- if (!msginfo) {
- log_warning(LOG_PROTOCOL, _("invalid xover line\n"));
- continue;
- }
+ if (msglist) {
+ for (cur = clist_begin(msglist); cur; cur = clist_next(cur)) {
+ struct newsnntp_xover_resp_item *ritem = (struct newsnntp_xover_resp_item *)clist_content(cur);
+ msginfo = news_parse_xover(ritem);
+
+ if (!msginfo) {
+ log_warning(LOG_PROTOCOL, _("invalid xover line\n"));
+ continue;
+ }
- msginfo->folder = item;
- news_set_msg_flags(item, msginfo);
- msginfo->flags.tmp_flags |= MSG_NEWS;
- msginfo->newsgroups = g_strdup(item->path);
+ msginfo->folder = item;
+ news_set_msg_flags(item, msginfo);
+ msginfo->flags.tmp_flags |= MSG_NEWS;
+ msginfo->newsgroups = g_strdup(item->path);
- if (!newlist)
- llast = newlist = g_slist_append(newlist, msginfo);
- else {
- llast = g_slist_append(llast, msginfo);
- llast = llast->next;
+ if (!newlist)
+ llast = newlist = g_slist_append(newlist, msginfo);
+ else {
+ llast = g_slist_append(llast, msginfo);
+ llast = llast->next;
+ }
}
+ newsnntp_xover_resp_list_free(msglist);
}
- newsnntp_xover_resp_list_free(msglist);
news_folder_unlock(NEWS_FOLDER(item->folder));