e15abb4222
from Brad, ok sthen@
51 lines
1.7 KiB
Plaintext
51 lines
1.7 KiB
Plaintext
$OpenBSD: patch-src_css_c,v 1.2 2012/05/03 06:50:09 ajacoutot Exp $
|
|
--- src/css.c.orig Mon Nov 14 05:00:53 2011
|
|
+++ src/css.c Mon Dec 12 05:39:54 2011
|
|
@@ -218,10 +218,13 @@ int _dvdcss_title ( dvdcss_t dvdcss, int i_block )
|
|
{
|
|
char psz_key[KEY_SIZE * 3];
|
|
unsigned int k0, k1, k2, k3, k4;
|
|
+ int n;
|
|
|
|
- psz_key[KEY_SIZE * 3 - 1] = '\0';
|
|
+ memset(psz_key, 0, sizeof psz_key);
|
|
+ n = read( i_fd, psz_key, KEY_SIZE * 3 - 1 );
|
|
+ close( i_fd );
|
|
|
|
- if( read( i_fd, psz_key, KEY_SIZE * 3 - 1 ) == KEY_SIZE * 3 - 1
|
|
+ if( n == KEY_SIZE * 3 - 1
|
|
&& sscanf( psz_key, "%x:%x:%x:%x:%x",
|
|
&k0, &k1, &k2, &k3, &k4 ) == 5 )
|
|
{
|
|
@@ -235,9 +238,12 @@ int _dvdcss_title ( dvdcss_t dvdcss, int i_block )
|
|
/* Don't try to save it again */
|
|
b_cache = 0;
|
|
i_ret = 1;
|
|
+ }
|
|
+ else if (n > 0 && strcmp(psz_key, PACKAGE_VERSION "\n") == 0)
|
|
+ {
|
|
+ /* didn't crack it, negative caching */
|
|
+ return -1;
|
|
}
|
|
-
|
|
- close( i_fd );
|
|
}
|
|
}
|
|
|
|
@@ -249,6 +255,15 @@ int _dvdcss_title ( dvdcss_t dvdcss, int i_block )
|
|
if( i_ret < 0 )
|
|
{
|
|
print_error( dvdcss, "fatal error in vts css key" );
|
|
+ i_fd = open( dvdcss->psz_cachefile, O_RDWR|O_CREAT, 0644 );
|
|
+ if( i_fd >= 0 )
|
|
+ {
|
|
+ char message[sizeof(PACKAGE_VERSION) + 3];
|
|
+
|
|
+ sprintf( message, "%s\n", PACKAGE_VERSION);
|
|
+ write( i_fd, message, strlen(message) );
|
|
+ close( i_fd );
|
|
+ }
|
|
return i_ret;
|
|
}
|
|
|