Michal Sojka via isync-devel <isync-devel@lists.sourceforge.net> writes:

> Hi,
>
> I'm currently trying to use mbsync with XOAUTH2 authentication (needed
> for Office365 mailboxes) and I encounter "Fatal: buffer too small.
> Please report a bug." error.

I use a similiar setting (mbsync + mu4e on Emacs) although I am on
macOS.

>
> Debugging with GDB revealed that the access token used for the LOGIN
> command does not fit into the imap_vprintf buffer, which is currently
> 1000 characters long. In my case, I needed the buffer to hold at least
> 2000 characters.

I tried to compile it and test it, and I can even run succesfully when the 
buffer length is reduced to only 100.

>
> I see that in the current master, the size of the buffer can be
> increased by defining QPRINTF_BUFF during compilation, but for the
> latest released version 1.4.4, I'm using the following patch. To make
> the size of the buffer more future-proof, I increase the buffer size to
> 4000 characters. Maybe, somebody will find it useful.
>
> Best regards,
> -Michal
>
> From e8a3a20aed135272a9ec0103f4055411c075f043 Mon Sep 17 00:00:00 2001
> From: Michal Sojka <michal.so...@cvut.cz>
> Date: Mon, 7 Nov 2022 00:07:22 +0100
> Subject: [PATCH] Increase imap_vprintf buffer size
> ---
>  src/drv_imap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/drv_imap.c b/src/drv_imap.c
> index c5a7aed..7847192 100644
> --- a/src/drv_imap.c
> +++ b/src/drv_imap.c
> @@ -528,7 +528,7 @@ imap_vprintf( const char *fmt, va_list ap )
>       uint totlen = 0;
>       const char *segs[MAX_SEGS];
>       uint segls[MAX_SEGS];
> -     char buf[1000];
> +     char buf[4000];
>  
>       d = buf;
>       ed = d + sizeof(buf);

I think these things would be successful to the developer.
1. the debug logs; you can get that from =mbsync --debug=.
2. how long is your token length? this is mine: 1908 chars.
   ❯ oauth2ms | wc -c
   1908

   I have checked that I can pass the login without modify the length of
   =buf=. 

3. I also compile with ASAN on and does not find any errors.

As a result, I guess that XOAUTH2 is not the root cause for your error.

-- 
Best regards
Yu-Fu, Fu

Attachment: signature.asc
Description: PGP signature

_______________________________________________
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel

Reply via email to