From: boehme <boehme>
Date: Mon, 3 Dec 2001 22:23:49 +0000 (+0000)
Subject: swfdump: fix segfault and endless loop; improved action code output
X-Git-Tag: release-0-2-1~59
X-Git-Url: http://git.asbjorn.biz/?a=commitdiff_plain;h=69d7d2022ba5d1b8e2433a0a3b81ebdeaa950e68;p=swftools.git

swfdump: fix segfault and endless loop; improved action code output
---

diff --git a/lib/modules/swfaction.c b/lib/modules/swfaction.c
index 652fd6d..014730b 100644
--- a/lib/modules/swfaction.c
+++ b/lib/modules/swfaction.c
@@ -13,6 +13,8 @@
 
 #include "../rfxswf.h"
 
+#define MAX_LOOKUP 1024   // make cross references in dumps
+
 struct Action
 {
     int version;
@@ -229,7 +231,7 @@ int OpAdvance(char c, char*data)
 		return 1+4; //int
 	    } else if (type == 8) {
 		return 1+1; //lookup
-	    }
+	    } else return 1;
 	    break;
 	}
     }
@@ -242,8 +244,18 @@ void swf_DumpActions(ActionTAG*atag, char*prefix)
     int t;
     U8*data;
     char* cp;
-    if(!prefix) 
-	prefix="";
+    int entry = 0;
+
+#ifdef MAX_LOOKUP
+
+    char * lookup[MAX_LOOKUP];
+    memset(lookup,0x00,sizeof(lookup));
+
+#endif
+
+   if (!prefix)
+        prefix="";
+
     while(atag)
     {
 	U8 poollen = 0;
@@ -278,9 +290,14 @@ void swf_DumpActions(ActionTAG*atag, char*prefix)
 		} break;
 		case 'c': {
 		    printf(" String:\"%s\"", data);
+#ifdef MAX_LOOKUP
+                    if (entry<MAX_LOOKUP)
+		      lookup[entry++] = strdup(data);
+#endif
 	        } break;
 		case 'C': {
 		    poollen = *data;
+                    entry = 0;
 		    printf("(%d entries)", poollen);
 	    	} break;
 		case 's': {
@@ -312,6 +329,10 @@ void swf_DumpActions(ActionTAG*atag, char*prefix)
 			printf(" int:%d", *(int*)value);
 		    } else if (type == 8) {
 			printf(" Lookup:%d", *value);
+#ifdef MAX_LOOKUP
+			if (lookup[*value])
+			  printf(" (\"%s\")",lookup[*value]);
+#endif
 		    } else {
 			printf(" UNKNOWN[%02x]",type);
 		    }
@@ -341,6 +362,10 @@ void swf_DumpActions(ActionTAG*atag, char*prefix)
 	printf("\n");
 	atag = atag->next;
     }
+
+#ifdef MAX_LOOKUP
+  for (t=0;t<MAX_LOOKUP;t++) if (lookup[t]) free(lookup[t]);
+#endif
 }
 
 static const char TYPE_URL = 1;
diff --git a/src/swfdump.c b/src/swfdump.c
index 95c57d6..81dae0c 100644
--- a/src/swfdump.c
+++ b/src/swfdump.c
@@ -335,7 +335,7 @@ void handlePlaceObject2(TAG*tag, char*prefix)
 	    swf_ActionFree(a);
 	}
 	if(globalflags) // should go to sterr.
-	    printf("%s ERROR: unsatisfied handlerflags: %02x", globalflags);
+	    printf("ERROR: unsatisfied handlerflags: %02x", globalflags);
     } else {
       printf(" has action code\n");
     }