Alternate patch for bug 3093 -- backend.c doesn't compare offered mechanisms to conf file
Wesley Craig
wes at umich.edu
Mon Jul 6 17:20:20 EDT 2009
You should attach this to 3093 for consideration. Checking Bugzilla
can often save hours of work. I believe the only thing delaying my
patch from being incorporated into CVS is someone to review a
question I had. I suspect my question applies to your patch as well.
:wes
On 05 Jul 2009, at 23:52, Michael Bacon wrote:
> So I spent several hours today working on this patch, before I
> realized that Wesley Craig had already developed a patch. I notice
> that his hasn't been accepted into the trunk on CVS yet. Let me
> just state that this was a blocker bug for our implementation, and
> that I support some kind of fix being applied. Since I've already
> written it, I went ahead and attached the patch as I wrote it below
> -- same basic idea as Wesley's, but different implementation.
> Someone else can decide which to use... :)
>
> Another (new, I think) bug patch coming in just a sec....
>
> index: backend.c
> ===================================================================
> RCS file: /cvs/src/cyrus/imap/backend.c,v
> retrieving revision 1.59
> diff -u -r1.59 backend.c
> --- backend.c 4 Feb 2009 16:42:02 -0000 1.59
> +++ backend.c 6 Jul 2009 03:35:52 -0000
> @@ -134,6 +134,38 @@
> return ret;
> }
>
> +static void reconcile_mechs(char **list, const char *conflist)
> +{
> + char *new;
> + char *cur;
> + char *end;
> +
> + if (strlen(*list) == 0) {
> + return;
> + }
> +
> + /* Lazy way of getting a big enough buffer */
> + /* The new string should be no longer than the old */
> + new = xstrndup(*list, strlen(*list) + 1);
> + *new = '\0';
> +
> + for (cur = *list; cur != NULL; cur = end) {
> + if (end = strchr(cur, ' ')) {
> + *end = '\0';
> + end++;
> + }
> +
> + if (strstr(cur, conflist)) {
> + if (strlen(new)) {
> + strcat(new, " ");
> + }
> + strcat(new, cur);
> + }
> + }
> + free(*list);
> + *list = new;
> +}
> +
> static int do_starttls(struct backend *s, struct tls_cmd_t *tls_cmd)
> {
> #ifndef HAVE_SSL
> @@ -247,8 +279,7 @@
> do {
> /* If we have a mech_conf, use it */
> if (mech_conf) {
> - free(*mechlist);
> - *mechlist = xstrdup(mech_conf);
> + reconcile_mechs(mechlist, mech_conf);
> }
>
> if (*mechlist) {
More information about the Cyrus-devel
mailing list