Wrong length calculation on folded lines.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
dkimpy |
New
|
Undecided
|
Unassigned |
Bug Description
When folding, certain values will cause the folded line to exceed 72 by 1.
In dkim/__init__.py, a recent change to fold() changed "namelen = 0" to "maxleng = 72". This changes tries to address short folded lines. However, this change can potentially result in line lengths of 73 because it does not account for the space in the prepended "\r\n ". The correct change would be "maxleng = 71"
At lines 400-409, "i" is calculated as the offset to the first space (if any). If i == 72 (and maxleng==72), then the line will be appended to a line that already has one character, the space. If i == -1 (no space found), then the line will be folded with 72 characters and appended to a line that already has one character. In both these situations, the length of the line will be 73.
Correction: i cannot == 72, so that is not a problem, if i==71, then line is correctly limited to 72. If however i == -1, the problem still occurs.