patch-src_css_c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. $OpenBSD: patch-src_css_c,v 1.5 2015/04/27 12:16:02 ajacoutot Exp $
  2. --- src/css.c.orig Tue Jan 27 08:56:05 2015
  3. +++ src/css.c Tue Feb 10 14:33:01 2015
  4. @@ -230,10 +230,13 @@ int dvdcss_title ( dvdcss_t dvdcss, int i_block )
  5. {
  6. char psz_key[PSZ_KEY_SIZE];
  7. unsigned int k0, k1, k2, k3, k4;
  8. + int n;
  9. - psz_key[PSZ_KEY_SIZE - 1] = '\0';
  10. + memset(psz_key, 0, sizeof psz_key);
  11. + n = read( i_fd, psz_key, PSZ_KEY_SIZE - 1 );
  12. + close( i_fd );
  13. - if( read( i_fd, psz_key, PSZ_KEY_SIZE - 1 ) == PSZ_KEY_SIZE - 1
  14. + if( n == PSZ_KEY_SIZE - 1
  15. && sscanf( psz_key, "%x:%x:%x:%x:%x",
  16. &k0, &k1, &k2, &k3, &k4 ) == 5 )
  17. {
  18. @@ -247,9 +250,12 @@ int dvdcss_title ( dvdcss_t dvdcss, int i_block )
  19. /* Don't try to save it again */
  20. b_cache = 0;
  21. i_ret = 1;
  22. + }
  23. + else if (n > 0 && strcmp(psz_key, PACKAGE_VERSION "\n") == 0)
  24. + {
  25. + /* didn't crack it, negative caching */
  26. + return -1;
  27. }
  28. -
  29. - close( i_fd );
  30. }
  31. }
  32. @@ -263,6 +269,15 @@ int dvdcss_title ( dvdcss_t dvdcss, int i_block )
  33. {
  34. print_error( dvdcss, "fatal error in Video Title Set (VTS) "
  35. "Content Scrambling System (CSS) key" );
  36. + i_fd = open( dvdcss->psz_cachefile, O_RDWR|O_CREAT, 0644 );
  37. + if( i_fd >= 0 )
  38. + {
  39. + char message[sizeof(PACKAGE_VERSION) + 3];
  40. +
  41. + sprintf( message, "%s\n", PACKAGE_VERSION);
  42. + write( i_fd, message, strlen(message) );
  43. + close( i_fd );
  44. + }
  45. return i_ret;
  46. }