You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2013/07/04 00:37:33 UTC

[1/2] git commit: TS-1958: admin interface regex lookup seg fault

Updated Branches:
  refs/heads/master 3885e61a8 -> 7f24a8c49


TS-1958: admin interface regex lookup seg fault


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/c6968ede
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/c6968ede
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/c6968ede

Branch: refs/heads/master
Commit: c6968ede7fb764eacd517ab3d83c79819359f532
Parents: 3885e61
Author: James Peach <jp...@apache.org>
Authored: Tue Jun 18 15:38:29 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Wed Jul 3 15:22:06 2013 -0700

----------------------------------------------------------------------
 lib/ts/ink_defs.h |  4 +++
 proxy/Show.h      | 66 ++++++++++++++++++++++++++++----------------------
 2 files changed, 41 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c6968ede/lib/ts/ink_defs.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_defs.h b/lib/ts/ink_defs.h
index fb71b37..c42a23d 100644
--- a/lib/ts/ink_defs.h
+++ b/lib/ts/ink_defs.h
@@ -130,6 +130,10 @@ countof(const T (&)[N]) {
 #  include <hwloc.h>
 #endif
 
+#ifndef ROUNDUP
+#define ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y))
+#endif
+
 /* Debugging
 */
 #ifdef NDEBUG

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c6968ede/proxy/Show.h
----------------------------------------------------------------------
diff --git a/proxy/Show.h b/proxy/Show.h
index 1387b87..a6aabab 100644
--- a/proxy/Show.h
+++ b/proxy/Show.h
@@ -39,37 +39,48 @@ struct ShowCont;
 typedef int (ShowCont::*ShowContEventHandler) (int event, Event * data);
 struct ShowCont: public Continuation
 {
-  Action action;
+private:
   char *buf, *start, *ebuf;
-  int iarg;
+
+public:
+  Action action;
   char *sarg;
 
   int show(const char *s, ...)
   {
     va_list aap, va_scratch;
-    int l = ebuf - buf;
+    ptrdiff_t avail = ebuf - buf;
+    ptrdiff_t needed;
+
     va_start(aap, s);
     va_copy(va_scratch, aap);
-    int done = vsnprintf(buf, l, s, va_scratch);
+    needed = vsnprintf(buf, avail, s, va_scratch);
     va_end(va_scratch);
-    if (done > l - 256)
-    {
-      char *start2 = (char *)ats_realloc(start, (ebuf - start) * 2);
-        ebuf = start2 + (ebuf - start) * 2;
-        buf = start2 + (buf - start);
-        start = start2;
-        l = ebuf - buf;
-        done = vsnprintf(buf, l, s, aap);
-      if (done > l - 256)
-      {
-        va_end(aap);
+
+    if (needed >= avail) {
+      ptrdiff_t bufsz = ebuf - start;
+      ptrdiff_t used = buf - start;
+
+      Debug("cache_inspector", "needed %d bytes, reallocating to %d bytes",
+          (int)needed, (int)bufsz + (int)needed);
+
+      bufsz += ROUNDUP(needed, ats_pagesize());
+      start = (char *)ats_realloc(start, bufsz);
+      ebuf = start + bufsz;
+      buf = start + used;
+      avail = ebuf - buf;
+
+      needed = vsnprintf(buf, avail, s, aap);
+      va_end(aap);
+
+      if (needed >= avail) {
+        Debug("cache_inspector", "needed %d bytes, but had only %d",
+          (int)needed, (int)avail + (int)needed);
         return EVENT_DONE;
       }
-      buf += done;
-    } else
-      buf += done;
+    }
 
-    va_end(aap);
+    buf += needed;
     return EVENT_CONT;
   }
 
@@ -114,26 +125,23 @@ struct ShowCont: public Continuation
     NOWARN_UNUSED(e);
     NOWARN_UNUSED(event);
     NOWARN_UNUSED(data);
-    if (sarg) {
-      ats_free(sarg);
-      sarg = NULL;
-    }
     delete this;
     return EVENT_DONE;
   }
 
-ShowCont(Continuation * c, HTTPHdr * h):
-  Continuation(NULL), iarg(0), sarg(0) {
+  ShowCont(Continuation * c, HTTPHdr * h): Continuation(NULL), sarg(0) {
+    size_t sz = ats_pagesize();
     NOWARN_UNUSED(h);
     mutex = c->mutex;
     action = c;
-    buf = (char *)ats_malloc(32000);
+    buf = (char *)ats_malloc(sz);
     start = buf;
-    ebuf = buf + 32000;
+    ebuf = buf + sz;
   }
+
   ~ShowCont() {
-    if (start)
-      ats_free(start);
+    ats_free(sarg);
+    ats_free(start);
   }
 };
 


[2/2] git commit: TS-1958: web UI can crash doing a regex lookup

Posted by jp...@apache.org.
TS-1958: web UI can crash doing a regex lookup


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/7f24a8c4
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/7f24a8c4
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/7f24a8c4

Branch: refs/heads/master
Commit: 7f24a8c4916c5ac629d084743c8d736cbd4dba3d
Parents: c6968ed
Author: James Peach <jp...@apache.org>
Authored: Wed Jul 3 15:23:06 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Wed Jul 3 15:23:06 2013 -0700

----------------------------------------------------------------------
 CHANGES | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7f24a8c4/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 63dd5f2..c55f555 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@
   Changes with Apache Traffic Server 3.3.5
 
 
+  *) [TS-1958] Web UI can crash doing a regex lookup.
+
   *) [TS-1994] Increase default RAM cache size by a magnitude.
 
   *) [TS-1978] Segfault when trying to set an error from (remap) plugin. This