[libdvdcss-devel] [PATCH 32/47] device: Check return value of snprintf() in win2k_open()
Diego Biurrun
diego at biurrun.de
Wed Oct 29 21:33:32 CET 2014
This silences a complaint from the MSVC code analyzer.
---
src/device.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/device.c b/src/device.c
index c91f9a3..288fc93 100644
--- a/src/device.c
+++ b/src/device.c
@@ -465,7 +465,10 @@ static int libc_open ( dvdcss_t dvdcss, const char *psz_device )
static int win2k_open ( dvdcss_t dvdcss, const char *psz_device )
{
char psz_dvd[7];
- snprintf( psz_dvd, 7, "\\\\.\\%c:", psz_device[0] );
+ if( snprintf( psz_dvd, sizeof(psz_dvd), "\\\\.\\%c:", psz_device[0] ) < 0)
+ {
+ goto error;
+ }
/* To work around an M$ bug in IOCTL_DVD_READ_STRUCTURE, we need read
* _and_ write access to the device (so we can make SCSI Pass Through
@@ -489,13 +492,16 @@ static int win2k_open ( dvdcss_t dvdcss, const char *psz_device )
if( (HANDLE) dvdcss->i_fd == INVALID_HANDLE_VALUE )
{
- print_error( dvdcss, "failed opening device" );
- return -1;
+ goto error;
}
dvdcss->i_pos = 0;
return 0;
+
+error:
+ print_error( dvdcss, "failed opening device" );
+ return -1;
}
#endif /* defined( WIN32 ) */
--
1.9.1
More information about the libdvdcss-devel
mailing list