From fd4b67bbb4982683bfd6c137696b9fd4c37122cd Mon Sep 17 00:00:00 2001 From: Robert James Kaes Date: Wed, 11 Aug 2004 02:49:05 +0000 Subject: (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. --- src/reqs.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'src/reqs.c') diff --git a/src/reqs.c b/src/reqs.c index fc9375f..e371953 100644 --- a/src/reqs.c +++ b/src/reqs.c @@ -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'; } /* -- cgit v1.2.3