diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2007-02-23 19:45:09 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2007-02-23 19:45:09 +0000 |
commit | 38bc8f06eacaa5b5e9a70a7b54660968e6ed799a (patch) | |
tree | 14832336e51cb1dfcb0b5c9d153474fb58eb73e8 /libexec | |
parent | 1928a52e3abf7e784e5ece98fb453f65391e5080 (diff) |
make dequotetolower use regular string functions instead of the manual
walk with mutiple conditions in the loop.
ok deraadt@
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/spamd/grey.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/libexec/spamd/grey.c b/libexec/spamd/grey.c index 1bbb2dc5ab6..835e96b6a21 100644 --- a/libexec/spamd/grey.c +++ b/libexec/spamd/grey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grey.c,v 1.27 2007/02/23 19:36:23 deraadt Exp $ */ +/* $OpenBSD: grey.c,v 1.28 2007/02/23 19:45:08 beck Exp $ */ /* * Copyright (c) 2004-2006 Bob Beck. All rights reserved. @@ -202,16 +202,20 @@ char * dequotetolower(const char *addr) { static char buf[MAX_MAIL]; - int i; + char *cp; if (*addr == '<'); addr++; - for (i = 0; addr[i] != '\0' && i < sizeof(buf); i++) - buf[i] = tolower(addr[i]); - buf[i]='\0'; - if (i > 0 && buf[i-1] == '>') - buf[i-1] = '\0'; - return (buf); + (void) strlcpy(buf, addr, sizeof(buf)); + cp = strrchr(buf, '>'); + if (cp != NULL && cp[1] == '\0') + *cp = '\0'; + cp = buf; + while(*cp != '\0') { + *cp = tolower(*cp); + cp++; + } + return(buf); } void |