Hey Bill...
> + if (strchr(username, '/')) {
> + domain = apr_pstrndup(p, username, strchr(username, '/')-username);
> + username += strlen(domain) + 1;
> + }
> + else if (strchr(username, '\\')) {
> + domain = apr_pstrndup(p, username, strchr(username, '/')-username);
> + username += strlen(domain) + 1;
> + }
Two (actually 1.5) quick comments:
1) In the elseif block's apr_pstrndup(), I think the strchr() should look
for '\\', not '/'.
1.5) But that brings up the point that we don't really need to strchr()
twice for each block, or strlen() at all... if we save the value
from the first call, we can optimize a bit. Do you see any problem
with the following patch? Obviously, I have no way to even compile
it, so no guarantees that it works... but I think it should logically.
--Cliff
Index: userinfo.c
===================================================================
RCS file: /home/cvs/apr/user/win32/userinfo.c,v
retrieving revision 1.5
diff -u -d -r1.5 userinfo.c
--- userinfo.c 2001/02/21 23:38:45 1.5
+++ userinfo.c 2001/02/22 01:04:46
@@ -71,14 +71,15 @@
SID_NAME_USE sidtype;
char *domain = NULL;
DWORD sidlen, rv;
+ char *pos;
- if (strchr(username, '/')) {
- domain = apr_pstrndup(p, username, strchr(username, '/') - username);
- username += strlen(domain) + 1;
+ if (pos = strchr(username, '/')) {
+ domain = apr_pstrndup(p, username, pos - username);
+ username = pos + 1;
}
- else if (strchr(username, '\\')) {
- domain = apr_pstrndup(p, username, strchr(username, '/') - username);
- username += strlen(domain) + 1;
+ else if (pos = strchr(username, '\\')) {
+ domain = apr_pstrndup(p, username, pos - username);
+ username = pos + 1;
}
/* Get nothing on the first pass ... need to size the sid buffer
*/