[dovecot-cvs] dovecot/src/lib-storage mail-search.c,1.6,1.7
cras at procontrol.fi
cras at procontrol.fi
Thu Jan 2 10:09:29 EET 2003
- Previous message: [dovecot-cvs] dovecot/src/lib-imap imap-bodystructure.c,1.23,1.24 imap-envelope.c,1.17,1.18 imap-parser.c,1.27,1.28 imap-parser.h,1.6,1.7
- Next message: [dovecot-cvs] dovecot/src/lib-imap imap-parser.h,1.7,1.8
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/dovecot/src/lib-storage
In directory danu:/tmp/cvs-serv14058/lib-storage
Modified Files:
mail-search.c
Log Message:
Don't access ImapArg's union members directly - too easy to mess up. Fixes a
crash with feeding non-string parameters to SEARCH/SORT commands.
Index: mail-search.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/mail-search.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- mail-search.c 9 Dec 2002 15:06:41 -0000 1.6
+++ mail-search.c 2 Jan 2003 08:09:27 -0000 1.7
@@ -36,7 +36,13 @@
return FALSE;
}
- sarg->value.str = str_ucase((*args)->data.str);
+ if ((*args)->type != IMAP_ARG_ATOM &&
+ (*args)->type != IMAP_ARG_STRING) {
+ data->error = "Invalid parameter for argument";
+ return FALSE;
+ }
+
+ sarg->value.str = str_ucase(IMAP_ARG_STR(*args));
*args += 1;
/* second arg */
@@ -46,8 +52,14 @@
return FALSE;
}
+ if ((*args)->type != IMAP_ARG_ATOM &&
+ (*args)->type != IMAP_ARG_STRING) {
+ data->error = "Invalid parameter for argument";
+ return FALSE;
+ }
+
sarg->hdr_field_name = sarg->value.str;
- sarg->value.str = str_ucase((*args)->data.str);
+ sarg->value.str = str_ucase(IMAP_ARG_STR(*args));
*args += 1;
}
@@ -75,7 +87,7 @@
}
if (arg->type == IMAP_ARG_LIST) {
- ImapArg *listargs = arg->data.list->args;
+ ImapArg *listargs = IMAP_ARG_LIST(arg)->args;
*next_sarg = search_arg_new(data->pool, SEARCH_SUB);
subargs = &(*next_sarg)->value.subargs;
@@ -93,7 +105,7 @@
arg->type == IMAP_ARG_STRING);
/* string argument - get the name and jump to next */
- str = arg->data.str;
+ str = IMAP_ARG_STR(arg);
*args += 1;
str_ucase(str);
@@ -145,7 +157,13 @@
data->error = "Missing parameter for HEADER";
return FALSE;
}
- key = str_ucase((*args)->data.str);
+ if ((*args)->type != IMAP_ARG_ATOM &&
+ (*args)->type != IMAP_ARG_STRING) {
+ data->error = "Invalid parameter for HEADER";
+ return FALSE;
+ }
+
+ key = str_ucase(IMAP_ARG_STR(*args));
if (strcmp(key, "FROM") == 0) {
*args += 1;
@@ -221,7 +239,7 @@
break;
if ((*args)->type != IMAP_ARG_ATOM ||
- strcasecmp((*args)->data.str, "OR") != 0)
+ strcasecmp(IMAP_ARG_STR(*args), "OR") != 0)
break;
*args += 1;
- Previous message: [dovecot-cvs] dovecot/src/lib-imap imap-bodystructure.c,1.23,1.24 imap-envelope.c,1.17,1.18 imap-parser.c,1.27,1.28 imap-parser.h,1.6,1.7
- Next message: [dovecot-cvs] dovecot/src/lib-imap imap-parser.h,1.7,1.8
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list