Patches item #474259, was opened at 2001-10-23 22:01
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=303152&aid=474259&group_id=3152
Category: other
Group: None
Status: Open
Resolution: None
Priority: 6
Submitted By: Vinod Kurup (vkurup)
Assigned to: Kriston Rehberg (kriston)
Summary: ns_uuencode patch
Initial Comment:
Hello all,
ns_uuencode is broken in AOLServer 3.4.2. It works fine
for text content,
but it is broken for binary content. This is important
to me because
OpenACS needs a way to encode binary content when it
sends outgoing mail.
Rob Mayoff has explained to me that this is because
NsTclHTUUEncodeCmd is
currently implemented as a Tcl_CmdProc and it should be
implemented as a
Tcl_ObjCmdProc. He also notified me that this would
only work for Tcl8, so
I would have to keep the old Tcl_CmdProc for Tcl7.6
So, I've fixed this (according to his helpful guidance).
In order to do this, I've made the following changes:
* I created 2 header files (nsd76.h and nsd8x.h) which
contain the arrays
of commands for the 2 versions of Tcl. These arrays
used to be defined in
tclcmds.c.
* I've implemented the function NsTclCreateObjCmds
which previously was
declared, but never implemented.
* I've adjusted tclinit.c to call NsTclCreateObjCmds.
* Finally, I've removed NsTclHTUUEncodeCmd from
tclmisc.c and instead moved
it to a new file uuencode7.c. I've then implemented
the new
Tcl_ObjCmdProc version into uuencode8.c. These will
be included
conditionally from tclstub76.c and tcstub8x.c,
respectively.
I also included test cases and linked the from the main
test cases
index.adp page, so that they will get installed with a
'make install-tests'
These changes will also pave the way to upgrading other
procs to use
Tcl_ObjCmdProcs (such as ns_return, ns_write, etc).
I would love to see this applied to 3.4.2 so that we
could use AOLServer
3.4.x as the official distro for OpenACS 4. Let me know
if I can clarify
anything.
The patch is against CVS tagged nsd_v3_r4_p2
Additional files are attached:
nsd76.h, nsd8x.h, uuencode7.c and uuencode8.c go in
directory nsd/
binary-file, test1.adp and test2.adp go in a new folder
'uuencode' inside /tests
----------------------------------------------------------------------
Comment By: jrasmuss23 (jrasmuss23)
Date: 2002-07-24 10:30
Message:
Logged In: YES
user_id=522678
The patches supplied are not correct. When the patched
function is padding the array with zeros, it overwrites memory
it shouldn't be.
bytes = (char *) Tcl_GetByteArrayFromObj(objv[1], &nbytes);
...
padbytes = nbytes;
while (padbytes % 3 != 0) {
bytes[padbytes] = '\0';
padbytes++;
}
There is no guarantee that the buffer that bytes points to has
space to accommodate this padding. I think the patched
code should actually do something like:
char buffer[49];
...
bytes = (char *) Tcl_GetByteArrayFromObj(objv[1], &nbytes);
...
memset(buffer, 0, sizeof(buffer));
memcpy(buffer, bytes, nbytes);
I believe there is also another (very minor) bug in these
routines that is also in the AOLserver 4 CVS HEAD. The
buffer to receive the htuu encoded data is declared char
bufcoded[1 + (4 * 48) / 2];. I think it should actually be char
bufcoded[1 + (4 * 48) / 3];. This happens in both
NsTclHTUUEncodeCmd and NsTclHTUUEncodeObjCmd.
----------------------------------------------------------------------
Comment By: Vinod Kurup (vkurup)
Date: 2002-03-20 20:38
Message:
Logged In: YES
user_id=123505
Well, you're right - ns_uuencode is a misnomer because it
already does base64 encoding as it's written right now. This
patch simply allows ns_uuencode to base64-encode binary
content in addition to ASCII content. The actual encoding
process (in htuu.c) isn't changed at all, so it is still
valid for url encoding, etc.
----------------------------------------------------------------------
Comment By: Kriston Rehberg (kriston)
Date: 2002-03-20 16:06
Message:
Logged In: YES
user_id=16427
This is more appropriate as a separate command since
ns_uuencode is intended for "htuu" encoding for URLs and
basic auth (bug #446886). This patch would be great if it
were a different command entirely. Incidentally email
should use the more acceptable base-64 encoding. That way
you can take advantage of MIME email which is the more
compatible way to send binary data via email.
It's unfortunate that the command is still called
ns_uuencode but that's the way it is, I guess.
Let me know what you'd like to do. Is it really compatible
enough with htuu and basic-authentication to use this new
code for those things as well as data? Let me know.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=303152&aid=474259&group_id=3152