[Mplayer-cvslog] CVS: main/libmpdvdkit libdvdcss.c,1.4,1.5
Zoltan Ponekker
pontscho at mplayerhq.hu
Thu Apr 25 21:06:48 CEST 2002
Update of /cvsroot/mplayer/main/libmpdvdkit
In directory mail:/var/tmp.root/cvs-serv22661/libmpdvdkit
Modified Files:
libdvdcss.c
Log Message:
not write always the key file
Index: libdvdcss.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit/libdvdcss.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- libdvdcss.c 25 Apr 2002 18:35:04 -0000 1.4
+++ libdvdcss.c 25 Apr 2002 19:06:45 -0000 1.5
@@ -159,6 +159,8 @@
dvd_key_t p_key;
int i_ret;
char * key_file = NULL;
+ int not_saved = 1;
+ int need_key = 0;
if( ! dvdcss->b_encrypted )
{
@@ -186,37 +188,37 @@
if ( dvd_key_dir )
{
int fd;
-
+
if ( (key_file=calloc( 1,strlen( dvd_key_dir ) + 12 )) == NULL ) return -1;
sprintf( key_file,"%s/%0.10x",dvd_key_dir,i_block );
-
+
fprintf( stderr,"dvdcss: opening %s to look for key\n",key_file );
- if ( (fd=open( key_file,O_RDONLY ) ) < 0 )
+ if ( (fd=open( key_file,O_RDONLY ) ) > 0 )
{
- fprintf(stderr, "dvdcss: no such file, cracking normal\n");
- goto normal;
- }
- read(fd, p_key, 5);
- close( fd );
- goto goon;
+ read(fd, p_key, 5);
+ close( fd );
+ not_saved=0;
+ } else { need_key=1; fprintf(stderr, "dvdcss: no such file, cracking normal\n"); }
}
- normal:
- /* Crack CSS title key for current VTS */
- i_ret = CSSGetKey( dvdcss, i_block, p_key );
-
- if( i_ret < 0 )
- {
- _dvdcss_error( dvdcss, "fatal error in vts css key" );
- return i_ret;
- }
- else if( i_ret > 0 )
- {
- _dvdcss_error( dvdcss, "decryption unavailable" );
- return -1;
- }
- goon:
-
+ if ( need_key )
+ {
+ /* Crack CSS title key for current VTS */
+ i_ret = CSSGetKey( dvdcss, i_block, p_key );
+
+ if( i_ret < 0 )
+ {
+ _dvdcss_error( dvdcss, "fatal error in vts css key" );
+ return i_ret;
+ }
+ else
+ if( i_ret > 0 )
+ {
+ _dvdcss_error( dvdcss, "decryption unavailable" );
+ return -1;
+ }
+ }
+
//fprintf(stderr, "cracked key is %.2x %.2x %.2x %.2x %.2x\n",
// p_key[0], p_key[1], p_key[2], p_key[3], p_key[4] );
@@ -225,21 +227,18 @@
{
dvd_title_t *p_newtitle;
- if ( dvd_key_dir )
+ if ( ( dvd_key_dir )&&( not_saved ) )
{
int fd;
fprintf( stderr,"dvdcss: writing key to %s\n",key_file );
- if ( (fd=open( key_file,O_RDWR|O_CREAT|O_EXCL,0644 ) ) < 0 )
+ if ( (fd=open( key_file,O_RDWR|O_CREAT|O_EXCL,0644 ) ) > 0 )
{
-// fprintf(stderr, "dvdcss: file %s exists or write/permission error, doing nothing\n", tmp);
- goto normal2;
+ write( fd,p_key,5 );
+ close( fd );
+ free( key_file );
}
- write( fd,p_key,5 );
- close( fd );
- free( key_file );
}
- normal2:
/* Find our spot in the list */
p_newtitle = NULL;
p_title = dvdcss->p_titles;
More information about the MPlayer-cvslog
mailing list