Re: strippwd patch against CVS20041108
- From: Jindrich Novy <jnovy redhat com>
- To: me pavelsh pp ru
- Cc: MC Devel <mc-devel gnome org>, Leonard den Ottolander <leonard den ottolander nl>
- Subject: Re: strippwd patch against CVS20041108
- Date: Wed, 10 Nov 2004 18:07:08 +0100
Hello Pavel, Leonard,
On Wed, 2004-11-10 at 17:15, Jindrich Novy wrote:
> Hello Pavel,
>
> On Tue, 2004-11-09 at 20:10, me pavelsh pp ru wrote:
> > Hello Leonard,
> >
> > Tuesday, November 9, 2004, 7:13:26 PM, you wrote:
> >
> > LdO> These are the hunks of the strippwd patch that have not yet been
> > LdO> committed.
> >
> > Committed with my fixes.
>
> Note that your "fix" actually reintroduced the bug I've been trying to
> fix. So the path is now cut out again.
I checked out the latest CVS snapshot and see you fixed it. Thanks for
it, because moving the if (dir) condition before if (at) should fix the
path bug.
Anyway I don't agree with the style of the fix. The only different
functionality you did is that you seek for '@' backwards (strrchr) and
you need to zero out one character in p, which is also argument of the
function and the return it back to PATH_SEP.
The attached patch is doing the same thing, but without the ugly zero
and '/' return style. Note that the only change to do is to substitute
memchr with memrchr in my original patch.
Patch to the latest CVS snapshot is attached.
--
Jindrich Novy <jnovy redhat com>, http://people.redhat.com/jnovy/
--- mc-4.6.1-20041110/src/util.c.spw 2004-11-09 13:30:29.000000000 +0100
+++ mc-4.6.1-20041110/src/util.c 2004-11-10 17:47:49.000000000 +0100
@@ -443,6 +443,7 @@ strip_password (char *p, int has_prefix)
for (i = 0; i < sizeof (prefixes)/sizeof (prefixes[0]); i++) {
char *q;
+ size_t host_len;
if (has_prefix) {
if((q = strstr (p, prefixes[i].name)) == 0)
@@ -452,13 +453,12 @@ strip_password (char *p, int has_prefix)
}
if ((dir = strchr (p, PATH_SEP)) != NULL)
- *dir = '\0';
-
- /* search for any possible user */
- at = strrchr (p, '@');
+ host_len = dir - p;
+ else
+ host_len = strlen (p);
- if (dir)
- *dir = PATH_SEP;
+ /* Search for any possible user */
+ at = memrchr (p, '@', host_len);
/* We have a username */
if (at) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]