[libdvdcss-devel] device: Check return value of snprintf() in win2k_open()
[email protected] (Diego Biurrun)
| Newsgroups | gmane.comp.video.videolan.libdvdcss,gmane.comp.video.videolan.libdvdcss.devel |
|---|---|
| Message-ID | <[email protected]> |
libdvdcss | branch: master | Diego Biurrun <[email protected]> | Tue Oct 28 18:39:46 2014 +0100| [c5e38a058580410541842b9d1adcaf9d75bf86d3] | committer: Diego Biurrun device: Check return value of snprintf() in win2k_open() This silences a complaint from the MSVC code analyzer. > http://git.videolan.org/gitweb.cgi/libdvdcss.git/?a=commit;h=c5e38a058580410541842b9d1adcaf9d75bf86d3 --- src/device.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/device.c b/src/device.c index 06b2494..66c6151 100644 --- a/src/device.c +++ b/src/device.c @@ -489,7 +489,10 @@ static int libc_open ( dvdcss_t dvdcss, char const *psz_device ) static int win2k_open ( dvdcss_t dvdcss, char const *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 @@ -513,13 +516,16 @@ static int win2k_open ( dvdcss_t dvdcss, char const *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; } static int aspi_open( dvdcss_t dvdcss, char const * psz_device ) _______________________________________________ libdvdcss-devel mailing list [email protected] https://mailman.videolan.org/listinfo/libdvdcss-devel