diff options
author | Robert James Kaes <rjkaes@users.sourceforge.net> | 2004-08-11 02:49:05 +0000 |
---|---|---|
committer | Robert James Kaes <rjkaes@users.sourceforge.net> | 2004-08-11 02:49:05 +0000 |
commit | fd4b67bbb4982683bfd6c137696b9fd4c37122cd (patch) | |
tree | 68e8fff918d541cd2bbd513d0b484ced052a6a01 | |
parent | badc7673d06257b720444c785efa3fbd3233f69e (diff) |
(strip_username_password): Removed one of the pointer variables since
it's no longer needed. Reorganized the function to make it more
obvious what was actually being done.
-rw-r--r-- | src/reqs.c | 27 |
1 files changed, 16 insertions, 11 deletions
@@ -1,4 +1,4 @@ -/* $Id: reqs.c,v 1.113 2004-08-10 21:24:23 rjkaes Exp $ +/* $Id: reqs.c,v 1.114 2004-08-11 02:49:05 rjkaes Exp $ * * This is where all the work in tinyproxy is actually done. Incoming * connections have a new child created for them. The child then @@ -6,7 +6,7 @@ * and then relays the bytes between the two. * * Copyright (C) 1998 Steven Young - * Copyright (C) 1999-2002 Robert James Kaes (rjkaes@flarenet.com) + * Copyright (C) 1999-2004 Robert James Kaes (rjkaes@flarenet.com) * Copyright (C) 2000 Chris Lightfoot (chris@ex-parrot.com) * Copyright (C) 2002 Petr Lampa (lampa@fit.vutbr.cz) * @@ -204,17 +204,22 @@ free_request_struct(struct request_s *request) static void strip_username_password(char* host) { - char *ptr1, *ptr2; + char *p; - if ((ptr1 = strchr(host, '@')) != NULL) { - ptr1++; /* move to one past the @ symbol */ - ptr2 = host; + assert(host); + assert(strlen(host) > 0); - /* copy the bytes up to the NUL */ - while (*ptr1) - *ptr2++ = *ptr1++; - *ptr2 = '\0'; - } + if ((p = strchr(host, '@')) == NULL) + return; + + /* + * Move the pointer past the "@" and then copy from that point + * until the NUL to the beginning of the host buffer. + */ + p++; + while (*p) + *host++ = *p++; + *host = '\0'; } /* |