You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficserver.apache.org by SolidWallOfCode <gi...@git.apache.org> on 2017/03/16 15:13:20 UTC

[GitHub] trafficserver pull request #1567: [RFC] Diags scrubbing mechanism

Github user SolidWallOfCode commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/1567#discussion_r106444345
  
    --- Diff: lib/ts/Diags.cc ---
    @@ -926,3 +917,29 @@ Diags::rebind_stderr(int new_fd)
       }
       return false;
     }
    +
    +void
    +Diags::vprintline(FILE *fp, char *buffer, va_list ap) const
    +{
    +  int nbytes = strlen(buffer);
    +
    +  // check if we need to scrub any patterns
    +  if (unlikely(scrub_enabled)) {
    +    char _buf[MAX_LOG_LINE_SIZE];
    +    int r = vsnprintf(_buf, MAX_LOG_LINE_SIZE, buffer, ap);
    +    if (r > MAX_LOG_LINE_SIZE) {
    +      sprintf(_buf, "[WARN] Diags log line too long, dropping log\n");
    +    } else if (r < 0) {
    +      sprintf(_buf, "[WARN] Diags log line failed to encode with vsnprintf\n");
    +    }
    +    scrubber->scrub_buffer(_buf);
    +    fprintf(fp, "%s", _buf);
    --- End diff --
    
    Should probably just `strlcpy` here, although the `fprintf` is likely almost as fast.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---