On Tue, 14 Mar 2006, Reimar Döffinger wrote:
Hi, On Tue, Mar 14, 2006 at 02:39:20PM -0500, Jeff D'Angelo wrote:
Let me know if you want anything else from me for the libmpdemux/url.c patch from March 6 (updated patch from root folder attached).
Thanks for getting back to me so fast.
Hmm... Somehow didn't even see that one...
Ya, sorry. The bug this fixes and the patch got lost earlier in the thread.
@@ -86,12 +86,15 @@ // We got something, at least a username... int len = ptr2-ptr1; Curl->username = (char*)malloc(len+1); - if( Curl->username==NULL ) { + char *usernametmp = (char*)malloc(len+1); + if( Curl->username==NULL || usernametmp==NULL ) { mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed); goto err_out; } - strncpy(Curl->username, ptr1, len); - Curl->username[len] = '\0'; + strncpy(usernametmp, ptr1, len); + usernametmp[len] = '\0'; + url_unescape_string( Curl->username, usernametmp ); + free(usernametmp);
IMHO Ugly.
Honestly, I agree with you (see my note on the 6th). I knew there were a few different ways to go about it. I figured doing it the simplest way first could elicit a helpful response on which way to go.
Still ugly, but maybe better: Just do url_unescape_string( Curl->username, Curl->username );
Interesting. I guess that would work. Hadn't thought of it.
But maybe best (if it works, I think it should): *ptr2 = 0; and replace the strncpy by url_unescape_string.
I'm attracted to a possibly more elagant solution like this, too. Unfortunately, I think you break the rest of the parsing if you drop a null char in the middle of the string while you are still parsing it. Isn't ptr2 still used to find things like the optional port value? Maybe there's another trick here than can be used. Another way is to make an "n" version of url_unescape_string() to replace the strncpy() like I do in the enclosed patch. Let me know what you think. Thanks again. -- Jeff
Greetings, Reimar Döffinger
_______________________________________________ MPlayer-dev-eng mailing list MPlayer-dev-eng@mplayerhq.hu http://mplayerhq.hu/mailman/listinfo/mplayer-dev-eng