[Mailman-Developers] scrubber crash due to insanely long filename

Tomas Lindroos DC skitta at abo.fi
Wed Nov 10 13:39:35 CET 2004


Hello everybody,

I am running Mailman 2.1.5 and noticed this problem with the "senddigests" 
cron-job.

If a message has an attachment with a really long filename, Scrubber.py 
crashes:

---
Traceback (most recent call last):
   File "/export/mailman/cron/senddigests", line 94, in ?
     main()
   File "/export/mailman/cron/senddigests", line 86, in main
     mlist.send_digest_now()
   File "/export/mailman/Mailman/Digester.py", line 60, in send_digest_now
     ToDigest.send_digests(self, mboxfp)
   File "/export/mailman/Mailman/Handlers/ToDigest.py", line 132, in 
send_digests
     send_i18n_digests(mlist, mboxfp)
   File "/export/mailman/Mailman/Handlers/ToDigest.py", line 306, in 
send_i18n_digests
     msg = scrubber(mlist, msg)
   File "/export/mailman/Mailman/Handlers/Scrubber.py", line 240, in 
process
     url = save_attachment(mlist, part, dir)
   File "/export/mailman/Mailman/Handlers/Scrubber.py", line 445, in 
save_attachment
     fp = open(path, 'w')
IOError: [Errno 36] File name too long: 
'/var/mailman/archives/private/LISTNAME/attachments/20041007/16a8914c/INSANELY_LONG_FILENAME_WITH_320_CHARS_TOTAL.eml'
---

The problem didn't go away without admin intervention, and I suspect that 
no digest-mail was sent out while the problem persisted.

The actual bug seems to be that there is not a try-except-block around the 
open() call, if the call fails, the Scrubber fails. Perhaps it could be 
added?

To get around this particular problem, I made this small patch to 
Scrubber.py:

--- Scrubber.py~        Thu Sep 30 14:15:19 2004
+++ Scrubber.py Wed Nov 10 11:51:21 2004
@@ -396,6 +396,10 @@
          # after filebase, e.g. msgdir/filebase-cnt.ext
          counter = 0
          extra = ''
+        # check for insanely long filenames
+        if len(filebase + extra + ext)>=256:
+            filebase=filebase[:255-5-len(ext)] # 5 chars for extra
+
          while True:
              path = os.path.join(fsdir, filebase + extra + ext)
              # Generally it is not a good idea to test for file existance

Now, this is not a perfect solution, since the same problem will occur if 
the string "extra" becomes longer than 5 chars in the while-loop below. 
Perhaps the 5 should be substituted by min(5,len(extra)) or something...

This is not thouroghly tested, I just wanted to get the digests working 
again, so there may be pitfalls I didn't think of. Someone else with more 
insight into Mailman could probably implement this better.

(How to get 320 chars into a filename? Send an attachment with a 245 char 
long filename containing a lot of scandinavian or other 8-bit characters 
in it. Watch the åäö's get mangeled into a strings like 
'sE4ISO-8859-1QE4ntF6muutokset2C', and you'll have a lot more than 255 
chars in a while...)

 	/skitta

-- 
  Tomas 'Skitta' Lindroos. Planerare vid Datacentralen, UNIX-sektionen
                <skitta at abo.fi>, tel.nr. (215)4469


More information about the Mailman-Developers mailing list