Re: [MPlayer-dev-eng] http stream basic auth base64_encode() fix
On Mon, 6 Mar 2006, Reimar Döffinger wrote:
Hi, It's late so excuse any thinking-errors...
} else { - // Terminate with Mime style '=' - *out = '='; - outLen++; - - return outLen; + // Pad with 0 to 2 '=' chars as needed + if (outLen & 3) + memset(out, '=', 4 - (outLen & 3) ); + return (outLen + 3) & ~3;
Actually, IMHO memset is actually not a good idea in this case, I prefer your old patch in this regard. The real reason I posted my patch is because you do not check the maxlen value here and might be writing beyond the buffer.
Ahh I see it now. I was relying on the while( outLen<outMax ) loop to keep things in check as that would run after the last encode set. Rounding outLen down to be divisible by 4 should cover that.
So I think the best solution would be your original patch + my maxlen &= ~3; line.
Ok, how's this attached patch look? I added a couple speed ups to my original. -- Jeff
Greetings, Reimar Döffinger
_______________________________________________ MPlayer-dev-eng mailing list MPlayer-dev-eng@mplayerhq.hu http://mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
Hi, On Tue, Mar 07, 2006 at 11:26:18AM -0500, Jeff D'Angelo wrote:
Ok, how's this attached patch look? I added a couple speed ups to my original.
Fine, applied. Though you should create patches from the root of the CVS tree, makes it easier to apply. Greetings, Reimar Döffinger
On Wed, 8 Mar 2006, Reimar Döffinger wrote:
Hi, On Tue, Mar 07, 2006 at 11:26:18AM -0500, Jeff D'Angelo wrote:
Ok, how's this attached patch look? I added a couple speed ups to my original.
Fine, applied. Though you should create patches from the root of the CVS tree, makes it easier to apply.
Thanks, and I'll keep that in mind for the future. 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). -- Jeff
Greetings, Reimar Döffinger
_______________________________________________ MPlayer-dev-eng mailing list MPlayer-dev-eng@mplayerhq.hu http://mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
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).
Hmm... Somehow didn't even see that one...
@@ -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. Still ugly, but maybe better: Just do url_unescape_string( Curl->username, Curl->username ); But maybe best (if it works, I think it should): *ptr2 = 0; and replace the strncpy by url_unescape_string. Greetings, Reimar Döffinger
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
Hi, On Wed, Mar 15, 2006 at 12:02:24AM -0500, Jeff D'Angelo wrote:
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.
Completely went under in the stream of patches...
+/* the "n" version of url_unescape_string(), parallels strncpy() */ +void +url_unescape_nstring(char *outbuf, const char *inbuf, int len) +{ unsigned char c,c1,c2; - int i,len=strlen(inbuf); + int i;
esp. with that comment, there should be something to the effect of len = min(len, strlen(inbuf)). I'll try to have a closer look at this, but I'm drowning in my own patches already... Greetings, Reimar Döffinger
participants (2)
-
Jeff D'Angelo -
Reimar Döffinger