Mercurial > mplayer.hg
comparison Gui/skin/skin.c @ 12646:9a495bdc3a1e
string handling security fixes
patch by Nicholas Kain, Alexander Strasser <eclipse7@gmx.net>
reviewed by Pontscho, Alex, Rich
author | diego |
---|---|
date | Fri, 25 Jun 2004 16:49:53 +0000 |
parents | 31564f53c400 |
children | c30e193ac112 |
comparison
equal
deleted
inserted
replaced
12645:3841ef14a481 | 12646:9a495bdc3a1e |
---|---|
114 | 114 |
115 int cmd_window( char * in ) | 115 int cmd_window( char * in ) |
116 { | 116 { |
117 CHECKDEFLIST( "window" ); | 117 CHECKDEFLIST( "window" ); |
118 | 118 |
119 strcpy( window_name,strlower( in ) ); | 119 strlcpy( window_name,strlower( in ),sizeof( window_name ) ); |
120 if ( !strncmp( in,"main",4 ) ) { currSection=&skinAppMPlayer->main; currSubItem=&skinAppMPlayer->NumberOfItems; currSubItems=skinAppMPlayer->Items; } | 120 if ( !strncmp( in,"main",4 ) ) { currSection=&skinAppMPlayer->main; currSubItem=&skinAppMPlayer->NumberOfItems; currSubItems=skinAppMPlayer->Items; } |
121 else if ( !strncmp( in,"sub",3 ) ) currSection=&skinAppMPlayer->sub; | 121 else if ( !strncmp( in,"sub",3 ) ) currSection=&skinAppMPlayer->sub; |
122 else if ( !strncmp( in,"playbar",7 ) ) { currSection=&skinAppMPlayer->bar; currSubItem=&skinAppMPlayer->NumberOfBarItems; currSubItems=skinAppMPlayer->barItems; } | 122 else if ( !strncmp( in,"playbar",7 ) ) { currSection=&skinAppMPlayer->bar; currSubItem=&skinAppMPlayer->NumberOfBarItems; currSubItems=skinAppMPlayer->barItems; } |
123 else if ( !strncmp( in,"menu",4 ) ) { currSection=&skinAppMPlayer->menuBase; currSubItem=&skinAppMPlayer->NumberOfMenuItems; currSubItems=skinAppMPlayer->MenuItems; } | 123 else if ( !strncmp( in,"menu",4 ) ) { currSection=&skinAppMPlayer->menuBase; currSubItem=&skinAppMPlayer->NumberOfMenuItems; currSubItems=skinAppMPlayer->MenuItems; } |
124 else ERRORMESSAGE( "Unknown window type found ..." ); | 124 else ERRORMESSAGE( "Unknown window type found ..." ); |
145 if ( !strcmp( window_name,"main" ) ) | 145 if ( !strcmp( window_name,"main" ) ) |
146 { | 146 { |
147 defList->main.x=x; | 147 defList->main.x=x; |
148 defList->main.y=y; | 148 defList->main.y=y; |
149 defList->main.type=itBase; | 149 defList->main.type=itBase; |
150 strcpy( tmp,path ); strcat( tmp,fname ); | 150 strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, fname, sizeof( tmp )); |
151 if ( skinBPRead( tmp,&defList->main.Bitmap ) ) return 1; | 151 if ( skinBPRead( tmp,&defList->main.Bitmap ) ) return 1; |
152 defList->main.width=defList->main.Bitmap.Width; | 152 defList->main.width=defList->main.Bitmap.Width; |
153 defList->main.height=defList->main.Bitmap.Height; | 153 defList->main.height=defList->main.Bitmap.Height; |
154 #ifdef HAVE_XSHAPE | 154 #ifdef HAVE_XSHAPE |
155 Convert32to1( &defList->main.Bitmap,&defList->main.Mask,0x00ff00ff ); | 155 Convert32to1( &defList->main.Bitmap,&defList->main.Mask,0x00ff00ff ); |
160 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] width: %d height: %d\n",defList->main.width,defList->main.height ); | 160 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] width: %d height: %d\n",defList->main.width,defList->main.height ); |
161 } | 161 } |
162 if ( !strcmp( window_name,"sub" ) ) | 162 if ( !strcmp( window_name,"sub" ) ) |
163 { | 163 { |
164 defList->sub.type=itBase; | 164 defList->sub.type=itBase; |
165 strcpy( tmp,path ); strcat( tmp,fname ); | 165 strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, fname, sizeof( tmp )); |
166 if ( skinBPRead( tmp,&defList->sub.Bitmap ) ) return 1; | 166 if ( skinBPRead( tmp,&defList->sub.Bitmap ) ) return 1; |
167 defList->sub.x=x; | 167 defList->sub.x=x; |
168 defList->sub.y=y; | 168 defList->sub.y=y; |
169 defList->sub.width=defList->sub.Bitmap.Width; | 169 defList->sub.width=defList->sub.Bitmap.Width; |
170 defList->sub.height=defList->sub.Bitmap.Height; | 170 defList->sub.height=defList->sub.Bitmap.Height; |
177 } | 177 } |
178 if ( !strcmp( window_name,"menu" ) ) | 178 if ( !strcmp( window_name,"menu" ) ) |
179 { | 179 { |
180 defList->menuIsPresent=1; | 180 defList->menuIsPresent=1; |
181 defList->menuBase.type=itBase; | 181 defList->menuBase.type=itBase; |
182 strcpy( tmp,path ); strcat( tmp,fname ); | 182 strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, fname, sizeof( tmp )); |
183 if ( skinBPRead( tmp,&defList->menuBase.Bitmap ) ) return 1; | 183 if ( skinBPRead( tmp,&defList->menuBase.Bitmap ) ) return 1; |
184 defList->menuBase.width=defList->menuBase.Bitmap.Width; | 184 defList->menuBase.width=defList->menuBase.Bitmap.Width; |
185 defList->menuBase.height=defList->menuBase.Bitmap.Height; | 185 defList->menuBase.height=defList->menuBase.Bitmap.Height; |
186 #ifdef HAVE_XSHAPE | 186 #ifdef HAVE_XSHAPE |
187 Convert32to1( &defList->menuBase.Bitmap,&defList->menuBase.Mask,0x00ff00ff ); | 187 Convert32to1( &defList->menuBase.Bitmap,&defList->menuBase.Mask,0x00ff00ff ); |
195 { | 195 { |
196 defList->barIsPresent=1; | 196 defList->barIsPresent=1; |
197 defList->bar.x=x; | 197 defList->bar.x=x; |
198 defList->bar.y=y; | 198 defList->bar.y=y; |
199 defList->bar.type=itBase; | 199 defList->bar.type=itBase; |
200 strcpy( tmp,path ); strcat( tmp,fname ); | 200 strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, fname, sizeof( tmp )); |
201 if ( skinBPRead( tmp,&defList->bar.Bitmap ) ) return 1; | 201 if ( skinBPRead( tmp,&defList->bar.Bitmap ) ) return 1; |
202 defList->bar.width=defList->bar.Bitmap.Width; | 202 defList->bar.width=defList->bar.Bitmap.Width; |
203 defList->bar.height=defList->bar.Bitmap.Height; | 203 defList->bar.height=defList->bar.Bitmap.Height; |
204 #ifdef HAVE_XSHAPE | 204 #ifdef HAVE_XSHAPE |
205 Convert32to1( &defList->bar.Bitmap,&defList->bar.Mask,0x00ff00ff ); | 205 Convert32to1( &defList->bar.Bitmap,&defList->bar.Mask,0x00ff00ff ); |
266 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] message: %d\n",currSubItems[ *currSubItem ].msg ); | 266 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] message: %d\n",currSubItems[ *currSubItem ].msg ); |
267 | 267 |
268 currSubItems[ *currSubItem ].Bitmap.Image=NULL; | 268 currSubItems[ *currSubItem ].Bitmap.Image=NULL; |
269 if ( strcmp( fname,"NULL" ) ) | 269 if ( strcmp( fname,"NULL" ) ) |
270 { | 270 { |
271 strcpy( tmp,path ); strcat( tmp,fname ); | 271 strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, fname, sizeof( tmp )); |
272 if ( skinBPRead( tmp,&currSubItems[ *currSubItem ].Bitmap ) ) return 1; | 272 if ( skinBPRead( tmp,&currSubItems[ *currSubItem ].Bitmap ) ) return 1; |
273 } | 273 } |
274 | 274 |
275 return 0; | 275 return 0; |
276 } | 276 } |
287 CHECK( "sub" ); | 287 CHECK( "sub" ); |
288 CHECK( "playbar" ); | 288 CHECK( "playbar" ); |
289 | 289 |
290 cutItem( in,fname,',',0 ); | 290 cutItem( in,fname,',',0 ); |
291 defList->menuSelected.type=itBase; | 291 defList->menuSelected.type=itBase; |
292 strcpy( tmp,path ); strcat( tmp,fname ); | 292 strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, fname, sizeof( tmp )); |
293 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] selected: %s\n",fname ); | 293 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] selected: %s\n",fname ); |
294 if ( skinBPRead( tmp,&defList->menuSelected.Bitmap ) ) return 1; | 294 if ( skinBPRead( tmp,&defList->menuSelected.Bitmap ) ) return 1; |
295 defList->menuSelected.width=defList->menuSelected.Bitmap.Width; | 295 defList->menuSelected.width=defList->menuSelected.Bitmap.Width; |
296 defList->menuSelected.height=defList->menuSelected.Bitmap.Height; | 296 defList->menuSelected.height=defList->menuSelected.Bitmap.Height; |
297 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] width: %d height: %d\n",defList->menuSelected.width,defList->menuSelected.height ); | 297 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] width: %d height: %d\n",defList->menuSelected.width,defList->menuSelected.height ); |
379 item->pressed=btnReleased; | 379 item->pressed=btnReleased; |
380 | 380 |
381 item->Bitmap.Image=NULL; | 381 item->Bitmap.Image=NULL; |
382 if ( strcmp( phfname,"NULL" ) ) | 382 if ( strcmp( phfname,"NULL" ) ) |
383 { | 383 { |
384 strcpy( tmp,path ); strcat( tmp,phfname ); | 384 strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, phfname, sizeof( tmp )); |
385 if ( skinBPRead( tmp,&item->Bitmap ) ) return 1; | 385 if ( skinBPRead( tmp,&item->Bitmap ) ) return 1; |
386 } | 386 } |
387 | 387 |
388 item->Mask.Image=NULL; | 388 item->Mask.Image=NULL; |
389 if ( strcmp( pfname,"NULL" ) ) | 389 if ( strcmp( pfname,"NULL" ) ) |
390 { | 390 { |
391 strcpy( tmp,path ); strcat( tmp,pfname ); | 391 strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, pfname, sizeof( tmp )); |
392 if ( skinBPRead( tmp,&item->Mask ) ) return 1; | 392 if ( skinBPRead( tmp,&item->Mask ) ) return 1; |
393 } | 393 } |
394 return 0; | 394 return 0; |
395 } | 395 } |
396 | 396 |
443 item->value=(float)d; | 443 item->value=(float)d; |
444 | 444 |
445 item->Bitmap.Image=NULL; | 445 item->Bitmap.Image=NULL; |
446 if ( strcmp( phfname,"NULL" ) ) | 446 if ( strcmp( phfname,"NULL" ) ) |
447 { | 447 { |
448 strcpy( tmp,path ); strcat( tmp,phfname ); | 448 strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, phfname, sizeof( tmp )); |
449 if ( skinBPRead( tmp,&item->Bitmap ) ) return 1; | 449 if ( skinBPRead( tmp,&item->Bitmap ) ) return 1; |
450 } | 450 } |
451 return 0; | 451 return 0; |
452 } | 452 } |
453 | 453 |
653 } | 653 } |
654 | 654 |
655 FILE * skinFile; | 655 FILE * skinFile; |
656 | 656 |
657 void setname( char * item1, char * item2 ) | 657 void setname( char * item1, char * item2 ) |
658 { strcpy( fn,item1 ); strcat( fn,"/" ); strcat( fn,item2 ); strcpy( path,fn ); strcat( path,"/" ); strcat( fn,"/skin" ); } | 658 { |
659 strlcpy(fn, item1, sizeof( fn )); | |
660 strlcat(fn, "/", sizeof( fn )); strlcat(fn, item2, sizeof( fn )); | |
661 strlcpy(path, fn, sizeof( path )); strlcat(path, "/", sizeof( path )); | |
662 strlcat(fn, "/skin", sizeof( fn )); | |
663 } | |
659 | 664 |
660 int skinRead( char * dname ) | 665 int skinRead( char * dname ) |
661 { | 666 { |
662 unsigned char tmp[255]; | 667 unsigned char tmp[255]; |
663 unsigned char * ptmp; | 668 unsigned char * ptmp; |