123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- $OpenBSD: patch-src_css_c,v 1.5 2015/04/27 12:16:02 ajacoutot Exp $
- --- src/css.c.orig Tue Jan 27 08:56:05 2015
- +++ src/css.c Tue Feb 10 14:33:01 2015
- @@ -230,10 +230,13 @@ int dvdcss_title ( dvdcss_t dvdcss, int i_block )
- {
- char psz_key[PSZ_KEY_SIZE];
- unsigned int k0, k1, k2, k3, k4;
- + int n;
-
- - psz_key[PSZ_KEY_SIZE - 1] = '\0';
- + memset(psz_key, 0, sizeof psz_key);
- + n = read( i_fd, psz_key, PSZ_KEY_SIZE - 1 );
- + close( i_fd );
-
- - if( read( i_fd, psz_key, PSZ_KEY_SIZE - 1 ) == PSZ_KEY_SIZE - 1
- + if( n == PSZ_KEY_SIZE - 1
- && sscanf( psz_key, "%x:%x:%x:%x:%x",
- &k0, &k1, &k2, &k3, &k4 ) == 5 )
- {
- @@ -247,9 +250,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 );
- }
- }
-
- @@ -263,6 +269,15 @@ int dvdcss_title ( dvdcss_t dvdcss, int i_block )
- {
- print_error( dvdcss, "fatal error in Video Title Set (VTS) "
- "Content Scrambling System (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;
- }
-
|