[libdvdcss-devel] [PATCH 6/9] libdvdcss: Skip NULL checks at the end of set_cache_directory().
Diego Biurrun
diego at biurrun.de
Tue Nov 4 15:15:08 CET 2014
The code guarantees that values have been assigned at this point.
---
src/libdvdcss.c | 22 +++++++---------------
1 file changed, 7 insertions(+), 15 deletions(-)
diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index 65a6267..4fd8aae 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -260,22 +260,14 @@ static char *set_cache_directory( dvdcss_t dvdcss )
#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;
}
--
1.9.1
More information about the libdvdcss-devel
mailing list