Author: adrian.chadd
Date: Mon Feb  2 10:51:34 2009
New Revision: 13781

Modified:
    branches/LUSCA_HEAD/src/external_acl.c

Log:
strBuf() -> stringDupToC(). Again, because of the quoting related crack
going on, taking a temporary copy is less hassle than dicking around
with the rfc1738* routines for now.



Modified: branches/LUSCA_HEAD/src/external_acl.c
==============================================================================
--- branches/LUSCA_HEAD/src/external_acl.c      (original)
+++ branches/LUSCA_HEAD/src/external_acl.c      Mon Feb  2 10:51:34 2009
@@ -626,9 +626,11 @@
      request_t *request = ch->request;
      String sb = StringNull;
      int data_used = 0;
+    int do_free = 0;
      memBufReset(&mb);
      for (format = acl_data->def->format; format; format = format->next) {
        const char *str = NULL;
+       const char *str2 = NULL;
        switch (format->type) {
        case EXT_ACL_LOGIN:
            str = authenticateUserRequestUsername(request->auth_user_request);
@@ -670,26 +672,31 @@
            str = buf;
            break;
        case EXT_ACL_PATH:
-           str = strBuf(request->urlpath);
+           str = stringDupToC(&request->urlpath);
+           do_free = 1;
            break;
        case EXT_ACL_METHOD:
            str = request->method->string;
            break;
        case EXT_ACL_HEADER:
            sb = httpHeaderGetByName(&request->header, format->header);
-           str = strBuf(sb);
+           str = stringDupToC(&sb);
+           do_free = 1;
            break;
        case EXT_ACL_HEADER_ID:
            sb = httpHeaderGetStrOrList(&request->header, format->header_id);
-           str = strBuf(sb);
+           str = stringDupToC(&sb);
+           do_free = 1;
            break;
        case EXT_ACL_HEADER_MEMBER:
            sb = httpHeaderGetByNameListMember(&request->header, 
format->header,  
format->member, format->separator);
-           str = strBuf(sb);
+           str = stringDupToC(&sb);
+           do_free = 1;
            break;
        case EXT_ACL_HEADER_ID_MEMBER:
            sb = httpHeaderGetListMember(&request->header, format->header_id,  
format->member, format->separator);
-           str = strBuf(sb);
+           str = stringDupToC(&sb);
+           do_free = 1;
            break;
  #if USE_SSL
        case EXT_ACL_USER_CERT_RAW:
@@ -740,7 +747,8 @@
                }
                first = 0;
            }
-           str = strBuf(sb);
+           str = stringDupToC(&sb);
+           do_free = 1;
            break;

        case EXT_ACL_ACL:
@@ -752,11 +760,19 @@
            fatal("unknown external_acl format error");
            break;
        }
+
+       /* Save the original string pointer, in case it needs to be freed */
+       str2 = str;
+
+       /* If the string has 0 length, set it to NULL */
        if (str)
            if (!*str)
                str = NULL;
+
+       /* If the string is NULL (and, from above, 0 length), set it to "-" */
        if (!str)
            str = "-";
+
        if (!first)
            memBufAppend(&mb, " ", 1);
        if (acl_data->def->quote == QUOTE_METHOD_URL) {
@@ -767,6 +783,10 @@
        }
        stringClean(&sb);
        first = 0;
+
+       /* Free str2 if required */
+       if (do_free)
+               safe_free(str2);
      }
      if (!data_used) {
        for (arg = acl_data->arguments; arg; arg = arg->next) {

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"lusca-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/lusca-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to