X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Frfxswf.c;h=14ec250bccbe682c88a9ae0f5a86c41fcea44200;hb=4ca7f5a76f6cd8a8397ecb1078b87e038719a050;hp=09f89c5f7d8697a3d814a109366498d5292c70d1;hpb=74021a5785a3b96e71a515d25fb91cd4e8cbbea9;p=swftools.git diff --git a/lib/rfxswf.c b/lib/rfxswf.c index 09f89c5..14ec250 100644 --- a/lib/rfxswf.c +++ b/lib/rfxswf.c @@ -35,8 +35,15 @@ #include #endif // HAVE_ZLIB -#define LAME +#ifndef RFXSWF_DISABLESOUND +#ifdef HAVE_LAME #include "lame/lame.h" +#endif +#endif + +#ifdef HAVE_TIME_H +#include +#endif #include "./bitio.h" #include "./MD5.h" @@ -654,7 +661,23 @@ int swf_SetCXForm(TAG * t,CXFORM * cx,U8 alpha) void swf_SetPassword(TAG * t, const char * password) { /* WARNING: crypt_md5 is not reentrant */ - char* md5string = crypt_md5(password, "salt"); /* FIXME- get random salt */ + char salt[3]; + char* md5string; + +#if defined(HAVE_LRAND48) && defined(HAVE_SRAND48) && defined(HAVE_TIME_H) && defined(HAVE_TIME) + srand48(time(0)); + salt[0] = "abcdefghijklmnopqrstuvwxyz0123456789"[lrand48()%36]; + salt[1] = "abcdefghijklmnopqrstuvwxyz0123456789"[lrand48()%36]; +#else + salt[0] = 'l'; + salt[1] = '8'; + fprintf(stderr, "rfxswf: Warning- no usable random generator found\n"); + fprintf(stderr, "Your password will be vulnerable to dictionary attacks\n"); +#endif + + md5string = crypt_md5(password, salt); + + swf_SetU16(t,0); swf_SetString(t, md5string); } @@ -665,14 +688,25 @@ int swf_VerifyPassword(TAG * t, const char * password) char*md5, *salt; int n; + if(t->len >= 5 && t->pos==0 && + t->data[0] == 0 && + t->data[1] == 0) { + swf_GetU16(t); + } else { + printf("%d %d %d %d\n", t->len, t->pos, t->data[0], t->data[1]); + } + md5string1 = swf_GetString(t); - if(!strncmp(md5string1, "$1$",3 )) { + if(strncmp(md5string1, "$1$",3 )) { + fprintf(stderr, "rfxswf: no salt in pw string\n"); return 0; } x = strchr(md5string1+3, '$'); - if(!x) + if(!x) { + fprintf(stderr, "rfxswf: invalid salt format in pw string\n"); return 0; + } n = x-(md5string1+3); salt = (char*)malloc(n+1); memcpy(salt, md5string1+3, n); @@ -1043,6 +1077,14 @@ void swf_FoldAll(SWF*swf) } } +void swf_FoldAllTags(TAG*tag) +{ + SWF swf; + memset(&swf, 0, sizeof(swf)); + swf.firstTag = tag; + swf_FoldAll(&swf); +} + void swf_UnFoldAll(SWF*swf) { TAG*tag = swf->firstTag; @@ -1164,6 +1206,7 @@ int swf_WriteSWF2(struct writer_t*writer, SWF * swf) // Writes SWF to file, int frameCount=0; struct writer_t zwriter; int fileSize = 0; + int inSprite = 0; if (!swf) return -1; @@ -1183,10 +1226,12 @@ int swf_WriteSWF2(struct writer_t*writer, SWF * swf) // Writes SWF to file, t = swf->firstTag; frameCount = 0; - while(t) - { len += swf_WriteTag(-1, t); - if (t->id==ST_SHOWFRAME) frameCount++; - t = swf_NextTag(t); + while(t) { + len += swf_WriteTag(-1,t); + if(t->id == ST_DEFINESPRITE) inSprite++; + else if(t->id == ST_END && inSprite) inSprite--; + else if(t->id == ST_SHOWFRAME && !inSprite) frameCount++; + t = swf_NextTag(t); } { TAG t1; @@ -1344,6 +1389,7 @@ void swf_FreeTags(SWF * swf) // Frees all malloc'ed memory for t #include "modules/swfdump.c" #include "modules/swfshape.c" #include "modules/swftext.c" +#include "modules/swffont.c" #include "modules/swfobject.c" #include "modules/swfbutton.c" #include "modules/swftools.c"