BUG#: 8628
authorvenkat.puvvada <venkat.puvvada>
Mon, 5 Oct 2009 15:55:31 +0000 (15:55 +0000)
committervenkat.puvvada <venkat.puvvada>
Mon, 5 Oct 2009 15:55:31 +0000 (15:55 +0000)
TITLE: SLP Provider not advertizing Registered Profiles
DESCRIPTION: Changed lexers to use the dynamically allocated buffer rather than using fixed size buffer.

src/slp/slp_client/src/cmd-utils/slp_client/attr.l
src/slp/slp_client/src/cmd-utils/slp_client/filter.l
src/slp/slp_client/src/cmd-utils/slp_client/l_attr.cpp
src/slp/slp_client/src/cmd-utils/slp_client/l_filter.cpp
src/slp/slp_client/src/cmd-utils/slp_client/l_url.cpp
src/slp/slp_client/src/cmd-utils/slp_client/url.l

index 4d5a7fab4e75323824e43268368cbb88c5c0f04d..db0beb151e7e5081eb67d8c04e66b378bf9abbca 100644 (file)
@@ -76,8 +76,8 @@
 #include "y_attr.h"
 
 static int16 heapIndex;
-static char heap[2052];
-static char buf[2052];
+static char *heap;
+static char *buf;
 static char *_lslp_strdup(const char *s);
 void attrerror(const char *, ...);
 void attr_close_lexer(size_t handle);
@@ -185,24 +185,42 @@ val         (("\\"([a-fA-F0-9]{2}))|[^(),!<=>~\x00-\x1f])
 static char *_lslp_strdup(const char *s)
 {
   char *p = &heap[heapIndex];
-  do { heap[heapIndex++] = *s; }
-      while ((*s != 0x00) && (heapIndex < 2049) && (++s));
-  return(p);
+
+  while ((heap[heapIndex++] = *s++))
+      ;
+
+  return p;
 }
 
 void attr_close_lexer(size_t handle)
 {
-  PEGASUS_ASSERT(handle != 0);
+  PEGASUS_ASSERT(handle);
+  PEGASUS_ASSERT(buf);
+  PEGASUS_ASSERT(heap);
   attr_delete_buffer((YY_BUFFER_STATE)handle);
+  free(buf);
+  free(heap);
+  buf = heap = 0;
 }
 
 size_t attr_init_lexer(const char *s)
 {
-  memset(&buf[0], 0x00, 2052);
-  memset(&heap[0], 0x00, 2052);
+  size_t len = strlen(s) + 2;
+
+  if (!(heap = (char*)malloc(len)))
+  {
+      return 0;
+  }
+  if (!(buf = (char*)malloc(len)))
+  {
+      free (heap);
+      return 0;
+  }
   heapIndex = 0;
-  strncpy(&buf[0], s, 2052);
-  return((size_t) attr_scan_buffer(&buf[0], strlen(s) + 2));
+  strcpy(buf, s);
+  buf[len - 1] = 0;
+
+  return ((size_t) attr_scan_buffer(buf, len));
 }
 
 
index b3c43bbd8f6202375fbee18a80dbde126a9e044a..37fdba179eb3f66128297c4d502f7e027e931a5a 100644 (file)
@@ -84,8 +84,8 @@ extern char *lslp_logPath;
     NULL, 0, (s), __FILE__, __LINE__);
 */
 static int16 heapIndex;
-static char heap[2052];
-static char buf[2052];
+static char *heap;
+static char *buf;
 
 static char *_lslp_strdup(const char *s);
 void filter_close_lexer(size_t handle);
@@ -168,32 +168,46 @@ not_reserved            [^()\&|!=<>~\n]
 
 %%
 
+static char *_lslp_strdup(const char *s)
+{
+  char *p = &heap[heapIndex];
+  
+  while ((heap[heapIndex++] = *s++))
+      ;
+
+  return p;
+}
+
 void filter_close_lexer(size_t handle)
 {
-  PEGASUS_ASSERT(handle != 0);
+  PEGASUS_ASSERT(handle);
+  PEGASUS_ASSERT(buf);
+  PEGASUS_ASSERT(heap);
   filter_delete_buffer((YY_BUFFER_STATE)handle);
+  free(buf);
+  free(heap);
+  buf = heap = 0;
 }
 
-
 size_t filter_init_lexer(const char *s)
 {
-  memset(&buf[0], 0x00, 2052);
-  memset(&heap[0], 0x00, 2052);
-  heapIndex = 0;
-  strncpy(&buf[0], s, 2048);
-  return((size_t) filter_scan_buffer(&buf[0], strlen(s) + 2));
-}
+  size_t len = strlen(s) + 2;
 
-
-static char *_lslp_strdup(const char *s)
-{
-  char *p = &heap[heapIndex];
-  do
+  if (!(heap = (char*)malloc(len)))
   {
-    heap[heapIndex++] = *s;
+      return 0;
   }
-  while ((*s != 0x00) && (heapIndex < 2049) && (++s));
-  return(p);
+  if (!(buf = (char*)malloc(len)))
+  {
+      free (heap);
+      return 0;
+  }
+
+  heapIndex = 0;
+  strcpy(buf, s);
+  buf[len - 1] = 0;
+
+  return ((size_t) filter_scan_buffer(buf, len));
 }
 
 /*****
index 9636736a976aedc8ec9f5421f863f8cd0dc91d0e..0ad6f717e4a378b40f59c51a1f89616d478957c9 100644 (file)
@@ -21,7 +21,7 @@
 /* A lexical scanner generated by flex */
 
 /* Scanner skeleton version:
- * $Header: /cvs/MSB/pegasus/src/slp/slp_client/src/cmd-utils/slp_client/l_attr.cpp,v 1.16 2009/09/25 13:32:38 venkat.puvvada Exp $
+ * $Header: /cvs/MSB/pegasus/src/slp/slp_client/src/cmd-utils/slp_client/l_attr.cpp,v 1.17 2009/10/05 15:55:31 venkat.puvvada Exp $
  */
 
 #define FLEX_SCANNER
@@ -515,8 +515,8 @@ char *yytext;
 #include "y_attr.h"
 
 static int16 heapIndex;
-static char heap[2052];
-static char buf[2052];
+static char *heap;
+static char *buf;
 static char *_lslp_strdup(const char *s);
 void attrerror(const char *, ...);
 void attr_close_lexer(size_t handle);
@@ -1801,24 +1801,42 @@ int main()
 static char *_lslp_strdup(const char *s)
 {
   char *p = &heap[heapIndex];
-  do { heap[heapIndex++] = *s; }
-      while ((*s != 0x00) && (heapIndex < 2049) && (++s));
-  return(p);
+
+  while ((heap[heapIndex++] = *s++))
+      ;
+
+  return p;
 }
 
 void attr_close_lexer(size_t handle)
 {
-  PEGASUS_ASSERT(handle != 0);
+  PEGASUS_ASSERT(handle);
+  PEGASUS_ASSERT(buf);
+  PEGASUS_ASSERT(heap);
   attr_delete_buffer((YY_BUFFER_STATE)handle);
+  free(buf);
+  free(heap);
+  buf = heap = 0;
 }
 
 size_t attr_init_lexer(const char *s)
 {
-  memset(&buf[0], 0x00, 2052);
-  memset(&heap[0], 0x00, 2052);
+  size_t len = strlen(s) + 2;
+
+  if (!(heap = (char*)malloc(len)))
+  {
+      return 0;
+  }
+  if (!(buf = (char*)malloc(len)))
+  {
+      free (heap);
+      return 0;
+  }
   heapIndex = 0;
-  strncpy(&buf[0], s, 2052);
-  return((size_t) attr_scan_buffer(&buf[0], strlen(s) + 2));
+  strcpy(buf, s);
+  buf[len - 1] = 0;
+
+  return ((size_t) attr_scan_buffer(buf, len));
 }
 
 
index e74dd07701ebb99edc88defd6dbf2ccc9aa2426b..8efb64c0e4fe1603f5eca92e3a2db3133134b961 100644 (file)
@@ -21,7 +21,7 @@
 /* A lexical scanner generated by flex */
 
 /* Scanner skeleton version:
- * $Header: /cvs/MSB/pegasus/src/slp/slp_client/src/cmd-utils/slp_client/l_filter.cpp,v 1.18 2009/09/25 13:32:38 venkat.puvvada Exp $
+ * $Header: /cvs/MSB/pegasus/src/slp/slp_client/src/cmd-utils/slp_client/l_filter.cpp,v 1.19 2009/10/05 15:55:31 venkat.puvvada Exp $
  */
 
 #define FLEX_SCANNER
@@ -506,8 +506,8 @@ extern char *lslp_logPath;
     NULL, 0, (s), __FILE__, __LINE__);
 */
 static int16 heapIndex;
-static char heap[2052];
-static char buf[2052];
+static char *heap;
+static char *buf;
 
 static char *_lslp_strdup(const char *s);
 void filter_close_lexer(size_t handle);
@@ -1766,32 +1766,46 @@ int main()
 #line 169 "filter.l"
 
 
+static char *_lslp_strdup(const char *s)
+{
+  char *p = &heap[heapIndex];
+  
+  while ((heap[heapIndex++] = *s++))
+      ;
+
+  return p;
+}
+
 void filter_close_lexer(size_t handle)
 {
-  PEGASUS_ASSERT(handle != 0);
+  PEGASUS_ASSERT(handle);
+  PEGASUS_ASSERT(buf);
+  PEGASUS_ASSERT(heap);
   filter_delete_buffer((YY_BUFFER_STATE)handle);
+  free(buf);
+  free(heap);
+  buf = heap = 0;
 }
 
-
 size_t filter_init_lexer(const char *s)
 {
-  memset(&buf[0], 0x00, 2052);
-  memset(&heap[0], 0x00, 2052);
-  heapIndex = 0;
-  strncpy(&buf[0], s, 2048);
-  return((size_t) filter_scan_buffer(&buf[0], strlen(s) + 2));
-}
+  size_t len = strlen(s) + 2;
 
-
-static char *_lslp_strdup(const char *s)
-{
-  char *p = &heap[heapIndex];
-  do
+  if (!(heap = (char*)malloc(len)))
   {
-    heap[heapIndex++] = *s;
+      return 0;
   }
-  while ((*s != 0x00) && (heapIndex < 2049) && (++s));
-  return(p);
+  if (!(buf = (char*)malloc(len)))
+  {
+      free (heap);
+      return 0;
+  }
+
+  heapIndex = 0;
+  strcpy(buf, s);
+  buf[len - 1] = 0;
+
+  return ((size_t) filter_scan_buffer(buf, len));
 }
 
 /*****
index 838e750ca46a374377844b62310dbc648057e1a7..9a264eeada8456aee65f77bdfffa0d99594c9ec0 100644 (file)
@@ -21,7 +21,7 @@
 /* A lexical scanner generated by flex */
 
 /* Scanner skeleton version:
- * $Header: /cvs/MSB/pegasus/src/slp/slp_client/src/cmd-utils/slp_client/l_url.cpp,v 1.18 2009/09/25 13:32:38 venkat.puvvada Exp $
+ * $Header: /cvs/MSB/pegasus/src/slp/slp_client/src/cmd-utils/slp_client/l_url.cpp,v 1.19 2009/10/05 15:55:31 venkat.puvvada Exp $
  */
 
 #define FLEX_SCANNER
@@ -770,8 +770,8 @@ char *yytext;
 void urlerror(const char *, ...);
 
 static int16 heapIndex;
-static char heap[2052];
-static char buf[2052];
+static char *heap;
+static char *buf;
 /* special counter to exit the appletalk state */
 char atalk_state = 0;
 
@@ -2111,29 +2111,44 @@ int main()
 #line 239 "url.l"
 
 
+static char *_lslp_strdup(const char *s)
+{
+  char *p = &heap[heapIndex];
+
+  while ((heap[heapIndex++] = *s++))
+      ;
+  return p;
+}
 
 void url_close_lexer(size_t handle)
 {
-  PEGASUS_ASSERT(handle != 0);
+  PEGASUS_ASSERT(handle);
+  PEGASUS_ASSERT(buf);
+  PEGASUS_ASSERT(heap);
   url_delete_buffer((YY_BUFFER_STATE)handle);
+  free(buf);
+  free(heap);
+  buf = heap = 0;
 }
 
-
 size_t url_init_lexer(const char *s)
 {
-  memset(&buf[0], 0x00, 2052);
-  memset(&heap[0], 0x00, 2052);
+  size_t len = strlen(s) + 2;
+
+  if (!(heap = (char*)malloc(len)))
+  {
+      return 0;
+  }
+  if (!(buf = (char*)malloc(len)))
+  {
+      free (heap);
+      return 0;
+  }
   heapIndex = 0;
-  strncpy(&buf[0], s, 2048);
-  return((size_t) url_scan_buffer(&buf[0], strlen(s) + 2));
-}
-
+  strcpy(buf, s);
+  buf[len - 1] = 0;
 
-static char *_lslp_strdup(const char *s)
-{
-  char *p = &heap[heapIndex];
-  do { heap[heapIndex++] = *s; } while ((*s != 0x00) && (heapIndex < 2049) && (++s));
-  return(p);
+  return ((size_t) url_scan_buffer(buf, len));
 }
 
 void urlerror(const char *s, ...)
index 389a0246ab6742644e91541377d982bdb5d26ea0..edca9454ee1095be99ba0eb629efea3c1a809840 100644 (file)
@@ -76,8 +76,8 @@
 void urlerror(const char *, ...);
 
 static int16 heapIndex;
-static char heap[2052];
-static char buf[2052];
+static char *heap;
+static char *buf;
 /* special counter to exit the appletalk state */
 char atalk_state = 0;
 
@@ -238,29 +238,44 @@ ip6addr                   {hexpart}|{hexpart}":"{ip4addr}
 
 %%
 
+static char *_lslp_strdup(const char *s)
+{
+  char *p = &heap[heapIndex];
+
+  while ((heap[heapIndex++] = *s++))
+      ;
+  return p;
+}
 
 void url_close_lexer(size_t handle)
 {
-  PEGASUS_ASSERT(handle != 0);
+  PEGASUS_ASSERT(handle);
+  PEGASUS_ASSERT(buf);
+  PEGASUS_ASSERT(heap);
   url_delete_buffer((YY_BUFFER_STATE)handle);
+  free(buf);
+  free(heap);
+  buf = heap = 0;
 }
 
-
 size_t url_init_lexer(const char *s)
 {
-  memset(&buf[0], 0x00, 2052);
-  memset(&heap[0], 0x00, 2052);
+  size_t len = strlen(s) + 2;
+
+  if (!(heap = (char*)malloc(len)))
+  {
+      return 0;
+  }
+  if (!(buf = (char*)malloc(len)))
+  {
+      free (heap);
+      return 0;
+  }
   heapIndex = 0;
-  strncpy(&buf[0], s, 2048);
-  return((size_t) url_scan_buffer(&buf[0], strlen(s) + 2));
-}
-
+  strcpy(buf, s);
+  buf[len - 1] = 0;
 
-static char *_lslp_strdup(const char *s)
-{
-  char *p = &heap[heapIndex];
-  do { heap[heapIndex++] = *s; } while ((*s != 0x00) && (heapIndex < 2049) && (++s));
-  return(p);
+  return ((size_t) url_scan_buffer(buf, len));
 }
 
 void urlerror(const char *s, ...)