[libdvdcss-devel] [Git][videolan/libdvdcss][master] Squelch potential buffer overflow warning
Jean-Baptiste Kempf <[email protected]> Tue, 12 Feb 2019 15:03:15 +0100
| Newsgroups | gmane.comp.video.videolan.libdvdcss,gmane.comp.video.videolan.libdvdcss.devel |
|---|---|
| Message-ID | <[email protected]> |
--===============5840957071086904516== Content-Type: multipart/alternative; boundary="--==_mimepart_5c62d2237cdf4_1b4f3fc43d50dd40456312"; charset=UTF-8 Content-Transfer-Encoding: 7bit ----==_mimepart_5c62d2237cdf4_1b4f3fc43d50dd40456312 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Jean-Baptiste Kempf pushed to branch master at VideoLAN / libdvdcss Commits: f93ae872 by astian at 2019-02-12T14:03:03Z Squelch potential buffer overflow warning GCC 7.3 points out that a buffer of size PATH_MAX is being written to with data that can theoretically overflow (a string of maximum size PATH_MAX plus other constant-size strings). Fix this by replacing sprintf with snprintf. Signed-off-by: astian <[email protected]> Signed-off-by: Jean-Baptiste Kempf <[email protected]> - - - - - 1 changed file: - src/libdvdcss.c Changes: ===================================== src/libdvdcss.c ===================================== @@ -320,7 +320,19 @@ static int init_cache_dir( dvdcss_t dvdcss ) return -1; } - sprintf( psz_tagfile, "%s/" CACHE_TAG_NAME, dvdcss->psz_cachefile ); + i_ret = snprintf( psz_tagfile, PATH_MAX, "%s/" CACHE_TAG_NAME, + dvdcss->psz_cachefile ); + if ( i_ret < 0 || i_ret >= PATH_MAX) + { + if ( i_ret < 0) + print_error( dvdcss, "failed to compose cache directory tag path"); + else + print_error( dvdcss, "cache directory tag path too long: %s/" CACHE_TAG_NAME, + dvdcss->psz_cachefile ); + dvdcss->psz_cachefile[0] = '\0'; + return -1; + } + i_fd = open( psz_tagfile, O_RDWR|O_CREAT, 0644 ); if( i_fd >= 0 ) { View it on GitLab: https://code.videolan.org/videolan/libdvdcss/commit/f93ae872f22bc404aa998ef127242d2e10de1b3c -- View it on GitLab: https://code.videolan.org/videolan/libdvdcss/commit/f93ae872f22bc404aa998ef127242d2e10de1b3c You're receiving this email because of your account on code.videolan.org. ----==_mimepart_5c62d2237cdf4_1b4f3fc43d50dd40456312-- --===============5840957071086904516== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KbGliZHZkY3Nz LWRldmVsIG1haWxpbmcgbGlzdApsaWJkdmRjc3MtZGV2ZWxAdmlkZW9sYW4ub3JnCmh0dHBzOi8v bWFpbG1hbi52aWRlb2xhbi5vcmcvbGlzdGluZm8vbGliZHZkY3NzLWRldmVsCg== --===============5840957071086904516==--