overlay: Fix crash due to small debug buffer size

The debug buffer size is insufficient for newer targets with multiple
pipes. The code causing crash is enabled only if the PIPE_DEBUG macro
is enabled during local debugging.

We now increase the buffer size and also put some string operations under
the macro check for efficiency.

Change-Id: I4ad418d314fd8c7d374ccfdb0943dde44d968922
diff --git a/liboverlay/overlay.cpp b/liboverlay/overlay.cpp
index a15d0a8..3836f9e 100644
--- a/liboverlay/overlay.cpp
+++ b/liboverlay/overlay.cpp
@@ -70,9 +70,11 @@
             //fds
             if(mPipeBook[i].valid()) {
                 char str[32];
-                sprintf(str, "Unset pipe=%s dpy=%d; ",
+                sprintf(str, "Unset=%s dpy=%d; ",
                         PipeBook::getDestStr((eDest)i), mPipeBook[i].mDisplay);
+#if PIPE_DEBUG
                 strncat(mDumpStr, str, strlen(str));
+#endif
             }
             mPipeBook[i].destroy();
         }
@@ -112,9 +114,11 @@
         if(not mPipeBook[index].valid()) {
             mPipeBook[index].mPipe = new GenericPipe(dpy);
             char str[32];
-            snprintf(str, 32, "Set pipe=%s dpy=%d; ",
+            snprintf(str, 32, "Set=%s dpy=%d; ",
                      PipeBook::getDestStr(dest), dpy);
+#if PIPE_DEBUG
             strncat(mDumpStr, str, strlen(str));
+#endif
         }
     } else {
         ALOGD_IF(PIPE_DEBUG, "Pipe unavailable type=%d display=%d",
@@ -292,9 +296,11 @@
 }
 
 void Overlay::dump() const {
+#if PIPE_DEBUG
     if(strlen(mDumpStr)) { //dump only on state change
-        ALOGD_IF(PIPE_DEBUG, "%s\n", mDumpStr);
+        ALOGD("%s\n", mDumpStr);
     }
+#endif
 }
 
 void Overlay::getDump(char *buf, size_t len) {
diff --git a/liboverlay/overlay.h b/liboverlay/overlay.h
index cfceaff..3064c6a 100644
--- a/liboverlay/overlay.h
+++ b/liboverlay/overlay.h
@@ -153,7 +153,7 @@
     PipeBook mPipeBook[utils::OV_INVALID]; //Used as max
 
     /* Dump string */
-    char mDumpStr[256];
+    char mDumpStr[1024];
 
     /* Singleton Instance*/
     static Overlay *sInstance;