$OpenBSD: patch-src_dvdread_dvd_reader_c,v 1.1 2005/11/03 04:25:08 jolan Exp $
--- src/dvdread/dvd_reader.c.orig	Thu Sep 30 21:39:11 2004
+++ src/dvdread/dvd_reader.c	Sun Oct 10 21:53:17 2004
@@ -170,9 +170,9 @@ static int initAllCSSKeys( dvd_reader_t 
     for( title = 0; title < 100; title++ ) {
 	gettimeofday( &t_s, NULL );
 	if( title == 0 ) {
-	    sprintf( filename, "/VIDEO_TS/VIDEO_TS.VOB" );
+	    snprintf( filename, sizeof(filename), "/VIDEO_TS/VIDEO_TS.VOB" );
 	} else {
-	    sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, 0 );
+	    snprintf( filename, sizeof(filename), "/VIDEO_TS/VTS_%02d_%d.VOB", title, 0 );
 	}
 	start = UDFFindFile( dvd, filename, &len );
 	if( start != 0 && len != 0 ) {
@@ -190,7 +190,7 @@ static int initAllCSSKeys( dvd_reader_t 
 	if( title == 0 ) continue;
 	    
 	gettimeofday( &t_s, NULL );
-	sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, 1 );
+	snprintf( filename, sizeof(filename), "/VIDEO_TS/VTS_%02d_%d.VOB", title, 1 );
 	start = UDFFindFile( dvd, filename, &len );
 	if( start == 0 || len == 0 ) break;
 	    
@@ -583,7 +583,7 @@ static int findDirFile( const char *path
 
     while( ( ent = readdir( dir ) ) != NULL ) {
         if( !strcasecmp( ent->d_name, file ) ) {
-            sprintf( filename, "%s%s%s", path,
+            snprintf( filename, MAX_UDF_FILE_NAME_LEN, "%s%s%s", path,
                      ( ( path[ strlen( path ) - 1 ] == '/' ) ? "" : "/" ),
                      ent->d_name );
             return 0;
@@ -609,11 +609,11 @@ static int findDVDFile( dvd_reader_t *dv
     ret = findDirFile( dvd->path_root, nodirfile, filename );
     if( ret < 0 ) {
         /* Try also with adding the path, just in case. */
-        sprintf( video_path, "%s/VIDEO_TS/", dvd->path_root );
+        snprintf( video_path, sizeof(video_path), "%s/VIDEO_TS/", dvd->path_root );
         ret = findDirFile( video_path, nodirfile, filename );
         if( ret < 0 ) {
             /* Try with the path, but in lower case. */
-            sprintf( video_path, "%s/video_ts/", dvd->path_root );
+            snprintf( video_path, sizeof(video_path), "%s/video_ts/", dvd->path_root );
             ret = findDirFile( video_path, nodirfile, filename );
             if( ret < 0 ) {
                 return 0;
@@ -677,9 +677,9 @@ static dvd_file_t *DVDOpenVOBUDF( dvd_re
     dvd_file_t *dvd_file;
 
     if( title == 0 ) {
-        sprintf( filename, "/VIDEO_TS/VIDEO_TS.VOB" );
+        snprintf( filename, sizeof(filename), "/VIDEO_TS/VIDEO_TS.VOB" );
     } else {
-        sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, menu ? 0 : 1 );
+        snprintf( filename, sizeof(filename), "/VIDEO_TS/VTS_%02d_%d.VOB", title, menu ? 0 : 1 );
     }
     start = UDFFindFile( dvd, filename, &len );
     if( start == 0 ) return 0;
@@ -699,7 +699,7 @@ static dvd_file_t *DVDOpenVOBUDF( dvd_re
         int cur;
 
         for( cur = 2; cur < 10; cur++ ) {
-            sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, cur );
+            snprintf( filename, sizeof(filename), "/VIDEO_TS/VTS_%02d_%d.VOB", title, cur );
             if( !UDFFindFile( dvd, filename, &len ) ) break;
             dvd_file->filesize += len / DVD_VIDEO_LB_LEN;
         }
@@ -741,9 +741,9 @@ static dvd_file_t *DVDOpenVOBPath( dvd_r
         dvd_input_t dev;
 
         if( title == 0 ) {
-            sprintf( filename, "VIDEO_TS.VOB" );
+            snprintf( filename, sizeof(filename), "VIDEO_TS.VOB" );
         } else {
-            sprintf( filename, "VTS_%02i_0.VOB", title );
+            snprintf( filename, sizeof(filename), "VTS_%02i_0.VOB", title );
         }
         if( !findDVDFile( dvd, filename, full_path ) ) {
             free( dvd_file );
@@ -769,7 +769,7 @@ static dvd_file_t *DVDOpenVOBPath( dvd_r
     } else {
         for( i = 0; i < 9; ++i ) {
 
-            sprintf( filename, "VTS_%02i_%i.VOB", title, i + 1 );
+            snprintf( filename, sizeof(filename), "VTS_%02i_%i.VOB", title, i + 1 );
             if( !findDVDFile( dvd, filename, full_path ) ) {
                 break;
             }
@@ -805,16 +805,16 @@ dvd_file_t *DVDOpenFile( dvd_reader_t *d
     switch( domain ) {
     case DVD_READ_INFO_FILE:
         if( titlenum == 0 ) {
-            sprintf( filename, "/VIDEO_TS/VIDEO_TS.IFO" );
+            snprintf( filename, sizeof(filename),"/VIDEO_TS/VIDEO_TS.IFO" );
         } else {
-            sprintf( filename, "/VIDEO_TS/VTS_%02i_0.IFO", titlenum );
+            snprintf( filename, sizeof(filename), "/VIDEO_TS/VTS_%02i_0.IFO", titlenum );
         }
         break;
     case DVD_READ_INFO_BACKUP_FILE:
         if( titlenum == 0 ) {
-            sprintf( filename, "/VIDEO_TS/VIDEO_TS.BUP" );
+            snprintf( filename, sizeof(filename), "/VIDEO_TS/VIDEO_TS.BUP" );
         } else {
-            sprintf( filename, "/VIDEO_TS/VTS_%02i_0.BUP", titlenum );
+            snprintf( filename, sizeof(filename), "/VIDEO_TS/VTS_%02i_0.BUP", titlenum );
         }
         break;
     case DVD_READ_MENU_VOBS:
@@ -1098,8 +1098,8 @@ int DVDDiscID( dvd_reader_t *dvd, unsign
 	    }
 	    bytes_read = DVDReadBytes( dvd_file, buffer, file_size );
 	    if( bytes_read != file_size ) {
-		fprintf( stderr, "libdvdread: DVDDiscId read returned %zd bytes"
-			 ", wanted %zd\n", bytes_read, file_size );
+		fprintf( stderr, "libdvdread: DVDDiscId read returned %d bytes"
+			 ", wanted %d\n", bytes_read, file_size );
 		DVDCloseFile( dvd_file );
 		free( buffer_base );
 		return -1;
