[Mplayer-cvslog] CVS: main/libmpdemux dvdauth.h,1.6,1.7 dvdauth.c,1.16,1.17

LGB Z lgb at mplayerhq.hu
Sat Sep 21 18:04:29 CEST 2002


Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var/tmp.root/cvs-serv30216/libmpdemux

Modified Files:
	dvdauth.h dvdauth.c 
Log Message:
fix segmentation fault with -dvdkey, fix return value of dvd_css_descramble(), try to load css.so syms with AND without _ in syms' names. PLEASE TEST IT CURRENTLY I HAVE NO DVD DRIVE NOR A SINGLE VOB FILE ...

Index: dvdauth.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/dvdauth.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- dvdauth.h	4 Jan 2002 13:08:14 -0000	1.6
+++ dvdauth.h	21 Sep 2002 16:04:13 -0000	1.7
@@ -11,7 +11,7 @@
 
 int dvd_auth ( char *, char * );
 int dvd_import_key ( unsigned char * );
-int dvd_css_descramble ( u_char *, u_char * );
+void dvd_css_descramble ( u_char *, u_char * );
 
 #endif
 #endif

Index: dvdauth.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/dvdauth.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- dvdauth.c	16 Sep 2002 20:46:31 -0000	1.16
+++ dvdauth.c	21 Sep 2002 16:04:14 -0000	1.17
@@ -8,7 +8,14 @@
    2001		fibmap_mplayer to avoid uid=0 mplayer need (LGB)
    2001		Support for libcss with the new API (by ???)
    2002/Jan/04  Use dlopen to access libcss.so to avoid conflict with
-                libdvdread [now with only libcss with old API (LGB)          
+                libdvdread [now with only libcss with old API (LGB)
+   2002/Sep/21  Fix a bug which caused segmentation fault when using
+		-dvdkey option, since css.so was only loaded by -dvdauth.
+		(LGB, reported and suggested by "me andi" <wortelsapje at hotmail.com>)
+		Also some cosmetic fix with return value of dvd_css_descramble().
+   2002/Sep/21  Try to load css syms with AND without underscore at their
+		names, probably not only OpenBSD requires this so it's a
+		better solution (LGB).
 		
    TODO:
 		support for libcss libraries with new API		     */
@@ -76,6 +83,9 @@
 unsigned char *dvdimportkey=NULL;
 int descrambling=0;
 
+
+static int css_so_is_loaded=0;
+
 static void *dlid;
 static int (*dl_CSSisEncrypted)(int);
 static int (*dl_CSSAuthDisc)(int,char *);
@@ -84,7 +94,8 @@
 static int (*dl_CSSDecryptTitleKey)(char *, char *);
 static void (*dl_CSSDescramble)(u_char *, u_char *);
 
-dvd_css_descramble ( u_char *sec , u_char *key )
+
+void dvd_css_descramble ( u_char *sec , u_char *key )
 {
 	(*dl_CSSDescramble)(sec,key);
 }
@@ -189,6 +200,53 @@
 }
 
 
+static int dvd_load_css_so ( void )
+{
+	if (css_so_is_loaded) {
+		printf("DVD: warning: attempt to load css.so twice, ignoring.\n");
+		return 0;
+	}
+	if (!css_so) css_so=strdup("libcss.so");
+	printf("DVD: opening libcss.so as %s ...\n",css_so);
+	dlid=dlopen(css_so,RTLD_NOW);
+	if (!dlid) {
+		printf("DVD: dlopen: %s\n",dlerror());
+		return 1;
+	} printf("DVD: dlopen OK!\n");
+
+/* #ifdef __OpenBSD__
+#define CSS_DLSYM(v,s) if (!(v=dlsym(dlid,"_" s))) {\
+fprintf(stderr,"DVD: %s\n  Hint: use libcss version 0.1!\n",dlerror());\
+return 1; }
+#else
+#define CSS_DLSYM(v,s) if (!(v=dlsym(dlid,s))) {\
+fprintf(stderr,"DVD: %s\n  Hint: use libcss version 0.1!\n",dlerror());\
+return 1; }
+#endif */
+
+#define CSS_DLSYM(v,s) \
+if (!(v=dlsym(dlid,s))) {\
+	if (!(v=dlsym(dlid,"_" s))) {\
+		fprintf(stderr,"DVD: %s\n Hint: use libcss version 0.1!\n",dlerror());\
+		return 1;\
+	}\
+}
+
+
+	CSS_DLSYM(dl_CSSisEncrypted,"CSSisEncrypted");
+	CSS_DLSYM(dl_CSSAuthDisc,"CSSAuthDisc");
+	CSS_DLSYM(dl_CSSAuthTitle,"CSSAuthTitle");
+	CSS_DLSYM(dl_CSSGetASF,"CSSGetASF");
+	CSS_DLSYM(dl_CSSDecryptTitleKey,"CSSDecryptTitleKey");
+	CSS_DLSYM(dl_CSSDescramble,"CSSDescramble");
+
+#undef CSS_DLSYM
+
+	css_so_is_loaded=1;
+	return 0;
+}
+
+
 int dvd_import_key ( unsigned char *hexkey )
 {
 	unsigned char *t=key_title;
@@ -209,6 +267,7 @@
 	}
 	if (*hexkey) return 1;
 	printf("DVD: DVD key (requested): %02X%02X%02X%02X%02X\n",key_title[0],key_title[1],key_title[2],key_title[3],key_title[4]);
+	if (dvd_load_css_so()) return 1;
 	descrambling=1;
 	return 0;
 }
@@ -219,32 +278,7 @@
 {
     	DVDHandle dvd;  /* DVD device handle */
 
-	if (!css_so) css_so=strdup("libcss.so");
-	printf("DVD: opening libcss.so as %s ...\n",css_so);
-	dlid=dlopen(css_so,RTLD_NOW);
-	if (!dlid) {
-		printf("DVD: dlopen: %s\n",dlerror());
-		return 1;
-	} printf("DVD: dlopen OK!\n");
-
-#ifdef __OpenBSD__
-#define CSS_DLSYM(v,s) if (!(v=dlsym(dlid,"_" s))) {\
-fprintf(stderr,"DVD: %s\n  Hint: use libcss version 0.1!\n",dlerror());\
-return 1; }
-#else
-#define CSS_DLSYM(v,s) if (!(v=dlsym(dlid,s))) {\
-fprintf(stderr,"DVD: %s\n  Hint: use libcss version 0.1!\n",dlerror());\
-return 1; }
-#endif
-
-	CSS_DLSYM(dl_CSSisEncrypted,"CSSisEncrypted");
-	CSS_DLSYM(dl_CSSAuthDisc,"CSSAuthDisc");
-	CSS_DLSYM(dl_CSSAuthTitle,"CSSAuthTitle");
-	CSS_DLSYM(dl_CSSGetASF,"CSSGetASF");
-	CSS_DLSYM(dl_CSSDecryptTitleKey,"CSSDecryptTitleKey");
-	CSS_DLSYM(dl_CSSDescramble,"CSSDescramble");
-
-#undef CSS_DLSYM
+	if (dvd_load_css_so()) return 1;
 
 	if ((dvd=DVDOpenDevice(dev)) == DVDOpenFailed) {
 		fprintf(stderr,"DVD: cannot open DVD device \"%s\": %s.\n",




More information about the MPlayer-cvslog mailing list