Bug 770892

Summary: mutt - a minor bug in a debugging output of handler.c
Product: [Fedora] Fedora Reporter: Michal Jaegermann <michal>
Component: muttAssignee: Honza Horak <hhorak>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: unspecified    
Version: 16CC: hhorak, mlichvar, pertusus
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-01-05 15:38:00 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Michal Jaegermann 2011-12-30 02:08:24 UTC
Description of problem:

This is a side-effect of tracking down problems from bug 770782 but I think that I mention that for a completness.

With debugging code turned on mutt may get sometimes bogus messages
when saving base64 encoded attachments.  Like that:

handler.c:310 [mutt_decode_base64()]: didn't get a multiple of 4 chars.

This is from this code:

  while (len > 0)
  {
    for (i = 0 ; i < 4 && len > 0 ; len--)
    {
      if ((ch = fgetc (s->fpin)) == EOF)
        break;
      if (ch >= 0 && ch < 128 && (base64val(ch) != -1 || ch == '='))
        buf[i++] = ch;
    }
    if (i != 4)
    {
      dprint (2, (debugfile, "%s:%d [mutt_decode_base64()]: "
                  "didn't get a multiple of 4 chars.\n", __FILE__, __LINE__));
      break;
    }
......
  }

and a message may be bogus because it will happen also when i is 0 - which is definitely a multiple of 4 and means that we just finished decoding.

That does happen in "real life" but it is easy to construct simple demo example.
Just put into an attachment results of 'echo -n abc | base64', which comes to YWJj, followed by a new line.  Then the second run of 'while' loop starts with len set to 1, nothing is put in buf so i ends as 0 and 4*0 is deemed not to be a multiple of 4. :-)

To fix simply add 'i == 0 && break;' before "dprint" line.

Version-Release number of selected component (if applicable):
mutt-1.5.21

Additional info:
mutt as shipped in Fedora does not have a debugging compiled in (which would be useful on occasions) and besides this is only a suggestion that something went wrong when nothing like that really happened.

Comment 1 Honza Horak 2012-01-05 15:38:00 UTC
If I understand it correctly, the suggested fix doesn't influence the fedora package behavior at all, so closing it as WONTFIX for now.

What's more, I don't think we should compile with debugging messages by default, it should be used for debugging only. So I'd suggest you to report this bug to upstream (http://dev.mutt.org) or I can do it if you want.

Comment 2 Michal Jaegermann 2012-01-05 17:21:38 UTC
(In reply to comment #1)
> If I understand it correctly,

You do.  As I said "With debugging code turned on ..." and later "mutt as shipped in Fedora does not have a debugging compiled in".  This report was just not to forget in a week once I bumped into that (but once you figured out from where  this is coming this is just an extra noise).

> ... to report
> this bug to upstream (http://dev.mutt.org) or I can do it if you want.

Yes, please.  I hope that you already have all accounts required for that.

> What's more, I don't think we should compile with debugging messages by
> default,

They are on occasions useful in tracking down problems and are silent without an explicit option to activate them and then they are only stored in files.  OTOH it is not a very big deal to recompile mutt with debugging when really needed (but that requires some experience with a toolchain).

Comment 3 Honza Horak 2012-01-10 11:11:40 UTC
Upstream report: http://dev.mutt.org/trac/ticket/3558