ref: 28713727f398b3022e7cb1966ca005863a9e3e25
parent: 2aca6d8b6702b30907b2a6761e7ab0cb94f9a927
author: Diego Biurrun <[email protected]>
date: Tue Nov 4 08:21:05 EST 2014
libdvdcss: Skip NULL checks at the end of set_cache_directory(). The code guarantees that values have been assigned at this point.
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -260,22 +260,14 @@
#endif /* ! defined(_WIN32_IE) && _WIN32_IE >= 0x500 */
}
- /* Sanity check psz_cache value. */
- if( psz_cache != NULL )
+ /* Check that there is enough space for the cache directory path and the
+ * block filename. The +1 are path separators and terminating null byte. */
+ if( strlen( psz_cache ) + 1 + DISC_TITLE_LENGTH + 1 +
+ MANUFACTURING_DATE_LENGTH + 1 + STRING_KEY_SIZE + 1 +
+ CACHE_FILENAME_LENGTH + 1 > PATH_MAX )
{
- if( psz_cache[0] == '\0' )
- {
- return NULL;
- }
- /* Check that there is enough space for the cache directory path and the
- * block filename. The +1 are path separators and terminating null byte. */
- else if( strlen( psz_cache ) + 1 + DISC_TITLE_LENGTH + 1 +
- MANUFACTURING_DATE_LENGTH + 1 + STRING_KEY_SIZE + 1 +
- CACHE_FILENAME_LENGTH + 1 > PATH_MAX )
- {
- print_error( dvdcss, "cache directory name is too long" );
- return NULL;
- }
+ print_error( dvdcss, "cache directory name is too long" );
+ return NULL;
}
return psz_cache;
}