Mercurial > mplayer.hg
comparison libdvdcss/css.c @ 31100:45159a4b8815
libdvdcss: Fix potential format string crash; check RPC status on disc access.
This merges upstream revisions 223 and 224 + 225.
author | diego |
---|---|
date | Tue, 11 May 2010 11:10:28 +0000 |
parents | 9e9595c779cf |
children | b470391059f3 |
comparison
equal
deleted
inserted
replaced
31099:f43e87f69590 | 31100:45159a4b8815 |
---|---|
87 static int AttackPadding ( uint8_t const[], int, uint8_t * ); | 87 static int AttackPadding ( uint8_t const[], int, uint8_t * ); |
88 #endif | 88 #endif |
89 | 89 |
90 /***************************************************************************** | 90 /***************************************************************************** |
91 * _dvdcss_test: check if the disc is encrypted or not | 91 * _dvdcss_test: check if the disc is encrypted or not |
92 ***************************************************************************** | |
93 * Return values: | |
94 * 1: DVD is scrambled but can be read | |
95 * 0: DVD is not scrambled and can be read | |
96 * -1: could not get "copyright" information | |
97 * -2: could not get RPC information (reading the disc might be possible) | |
98 * -3: drive is RPC-II, region is not set, and DVD is scrambled: the RPC | |
99 * scheme will prevent us from reading the scrambled data | |
92 *****************************************************************************/ | 100 *****************************************************************************/ |
93 int _dvdcss_test( dvdcss_t dvdcss ) | 101 int _dvdcss_test( dvdcss_t dvdcss ) |
94 { | 102 { |
95 int i_ret, i_copyright; | 103 char const *psz_type, *psz_rpc; |
104 int i_ret, i_copyright, i_type, i_mask, i_rpc; | |
96 | 105 |
97 i_ret = ioctl_ReadCopyright( dvdcss->i_fd, 0 /* i_layer */, &i_copyright ); | 106 i_ret = ioctl_ReadCopyright( dvdcss->i_fd, 0 /* i_layer */, &i_copyright ); |
98 | 107 |
99 #ifdef WIN32 | 108 #ifdef WIN32 |
100 if( i_ret < 0 ) | 109 if( i_ret < 0 ) |
113 #endif | 122 #endif |
114 | 123 |
115 if( i_ret < 0 ) | 124 if( i_ret < 0 ) |
116 { | 125 { |
117 /* Since it's the first ioctl we try to issue, we add a notice */ | 126 /* Since it's the first ioctl we try to issue, we add a notice */ |
118 print_error( dvdcss, "css error: ioctl_ReadCopyright failed, " | 127 print_error( dvdcss, "css error: could not get \"copyright\"" |
119 "make sure there is a DVD in the drive, and that " | 128 " information, make sure there is a DVD in the drive," |
120 "you have used the correct device node." ); | 129 " and that you have used the correct device node." ); |
121 | 130 |
122 return i_ret; | 131 return -1; |
123 } | 132 } |
124 | 133 |
125 return i_copyright; | 134 print_debug( dvdcss, "disc reports copyright information 0x%x", |
135 i_copyright ); | |
136 | |
137 i_ret = ioctl_ReportRPC( dvdcss->i_fd, &i_type, &i_mask, &i_rpc); | |
138 | |
139 if( i_ret < 0 ) | |
140 { | |
141 print_error( dvdcss, "css error: could not get RPC status" ); | |
142 return -2; | |
143 } | |
144 | |
145 switch( i_rpc ) | |
146 { | |
147 case 0: psz_rpc = "RPC-I"; break; | |
148 case 1: psz_rpc = "RPC-II"; break; | |
149 default: psz_rpc = "unknown RPC scheme"; break; | |
150 } | |
151 | |
152 switch( i_type ) | |
153 { | |
154 case 0: psz_type = "no region code set"; break; | |
155 case 1: psz_type = "region code set"; break; | |
156 case 2: psz_type = "one region change remaining"; break; | |
157 case 3: psz_type = "region code set permanently"; break; | |
158 default: psz_type = "unknown status"; break; | |
159 } | |
160 | |
161 print_debug( dvdcss, "drive region mask %x, %s, %s", | |
162 i_mask, psz_rpc, psz_type ); | |
163 | |
164 if( i_copyright && i_rpc == 1 && i_type == 0 ) | |
165 { | |
166 print_error( dvdcss, "css error: drive will prevent access to " | |
167 "scrambled data" ); | |
168 return -3; | |
169 } | |
170 | |
171 return i_copyright ? 1 : 0; | |
126 } | 172 } |
127 | 173 |
128 /***************************************************************************** | 174 /***************************************************************************** |
129 * _dvdcss_title: crack or decrypt the current title key if needed | 175 * _dvdcss_title: crack or decrypt the current title key if needed |
130 ***************************************************************************** | 176 ***************************************************************************** |