|
2020-03-31
| ||
| 15:59 | • Closed ticket [b8e82d293b]: accepted -maxlen value breaks uuencode round trip</i... artifact: bc1d4be010 user: dgp | |
| 15:59 | [b8e82d293b] Restrict the options of [binary encode uuencode] to values that will not prevent abilit... check-in: 94b6f3c028 user: dgp tags: core-8-6-branch | |
| 15:21 | • Ticket [b8e82d293b] accepted -maxlen value breaks uuencode round trip status... artifact: 6a7b9029f4 user: dgp | |
| 14:48 | • Ticket [b8e82d293b]: 3 changes artifact: c7f3063a3d user: dgp | |
| 14:42 | • Ticket [b8e82d293b]: 3 changes artifact: 8eec4a1cd3 user: dgp | |
| 14:31 | • Ticket [b8e82d293b]: 3 changes artifact: 153ad0757f user: jan.nijtmans | |
| 14:30 | • Ticket [b8e82d293b]: 3 changes artifact: 35c276c0a3 user: jan.nijtmans | |
| 11:55 | • Ticket [b8e82d293b]: 3 changes artifact: 601b1dd3b9 user: dgp | |
| 10:30 | Other suggested solution for [b8e82d293b] check-in: cba0dea6a2 user: jan.nijtmans tags: bug-b8e82d293b-2 | |
| 09:08 | • Ticket [b8e82d293b] accepted -maxlen value breaks uuencode round trip status... artifact: 327579379a user: jan.nijtmans | |
| 06:17 | • Ticket [b8e82d293b]: 3 changes artifact: 01b9e3fd77 user: jan.nijtmans | |
|
2020-03-30
| ||
| 18:22 | • Ticket [b8e82d293b]: 3 changes artifact: f3b027f74a user: dgp | |
| 18:20 | • Ticket [b8e82d293b]: 4 changes artifact: bb49b1e06f user: dgp | |
| 18:02 | • Ticket [b8e82d293b]: 3 changes artifact: 8740b1cde9 user: dgp | |
| 17:00 | • Ticket [b8e82d293b]: 3 changes artifact: 949d1a9056 user: dgp | |
| 16:38 | • New ticket [b8e82d293b]. artifact: d4f9f3650b user: dgp | |
accepted -maxlen value breaks uuencode round trip
Closed / Fixedb8e82d293b6d1f98d7b1446750a70a22cadc1c49Created 7 years agoUpdated 7 years ago
Descriptionplain2020-03-30 16:38:24
% binary decode uuencode [binary encode uuencode -maxlen 3 abc] a*
Referenced by2
94b6f3c028[b8e82d293b] Restrict the options of [binary encode uuencode] to values that will not prevent ability of [binary decode uuencode] to decode the result. check-in2020-03-31 15:59:35cba0dea6a2Other suggested solution for [b8e82d293b] check-in2020-03-31 10:30:27
dgpplain2020-03-30 17:00:55
It appears that the constraints of the encoding itself demand that each line have length l where (l - 1) % 4 == 0. A first byte to encode a length, followed by some whole number of 4 byte groups, each encoding 3 bytes. This suggests legal values of -maxlen are 5, 9, 13, 17, ...., 61 (default), 65, ... SOME LIMIT TBD
dgpplain2020-03-30 18:02:07
Bug was introduced by this checkin https://core.tcl-lang.org/tcl/info/c001d40665 which intended to fix a bug https://core.tcl-lang.org/tcl/info/2152292 which essentially called for a complete rewrite because we were "doing it wrong". Unfortunately, doing it "right" makes an encoding that doesn't roundtrip.
dgpplain2020-03-30 18:20:10
Assigned to dkf just to get attention and input. I'd really like to be talked into the position that a uuencoder ought not have -maxlen or -wrapchar options in the first place, and ours only got them because of an implementation quirk that "forced" options intended for base64 onto uuencode too. Then we could have our option parser continue to tolerate them, but ignore them and always produce standard uuencode format (maxlen == 61, wrapchar == \n).
dgpplain2020-03-30 18:22:29
Some more examples: % set code [binary encode uuencode -maxlen 21 [string repeat abc 10]] /86)C86)C86)C86)C86)C /86)C86)C86)C86)C86)C % binary decode uuencode $code abcabcabcabcabcabcabcabcabcabc % set code [binary encode uuencode -maxlen 20 [string repeat abc 10]] .86)C86)C86)C86)C86( .8V%B8V%B8V%B8V%B8V$ "8F, % binary decode uuencode $code abcabcabcabcabØXØXØXØXØ@Ê
jan.nijtmansplain2020-03-31 06:17:15
Suggestion: How about rounding the -maxlen down to the first lower valid value? So -maxlen 6 behaves the same as -maxlen 5, just as -maxlen 8. That restores the round-trip, and still assures that the maximum line length is the supplied value. I think that's better than ignoring the values, however useless they may be. Maxlengths bigger than 77 (the absolute maximum, using length letter ']', should behave the same as -maxlen 77 Just my 2c
jan.nijtmanswiki2020-03-31 09:08:02
Correction to the previous comment: The maximum line length is 85, which results in the length character '_'.
% binary encode uuencode -maxlen 86 xxx line length out of range
So, it appears that that's already taken care of.
dgpplain2020-03-31 11:55:49
Thanks for the review and alternative solution. Will have a look. Meanwhile, can you confirm that allowing -wrapchar to be anything other than \n also breaks roundtrip? The requirement that each "line" of the encoded format must end in the \n character sure appears to be directly embedded in the decoder. Again, these options were not added to the uuencode encode because they were standard or useful. They were just accepted because they came along with the base64 encoder it once shared an implementation with.
jan.nijtmansplain2020-03-31 14:30:10
> Meanwhile, can you confirm that allowing -wrapchar to be anything other than \n also breaks roundtrip? Confirmed. There are two direct checks with '\n' in the code (tclBinary.c lines 2800 and 2837). This means that changing -wrapchar means no roundtrip. Does it really matter? This could simply be documented. Or ... a "-wrapchar" option could be added to uuencode too.... No problem for now, I think, just document it.
jan.nijtmansplain2020-03-31 14:31:34
> a "-wrapchar" option could be added to uuencode too.... Of course, I meant "uudecode" here
dgpplain2020-03-31 14:42:12
With the decoder we have, the values of -wrapchar that will not break it are those that match the description: A sequence of zero or more characters from the set: \v \f \t \r Followed by zero or one: \n Anything else will break decoding.
dgpplain2020-03-31 14:48:48
...modulo the existing hackery that pulls in the -wrapchar value as a byte array, so that characters like U+2109 that truncate to become \t also "work" in a way that must be surprising.
dgpplain2020-03-31 15:21:59
Added value checks to enforce that restriction. Still includes the (mythical?) user out there asking for \r\n With changes in place to keep both options within their valid range, and tests adjusted, I plan to accept this as a fix.
dgpplain2020-03-31 15:59:49
Fix accepted.
Log in (anonymous is fine) to add a comment.