From: Andrew M. <fit...@us...> - 2007-12-02 15:36:09
|
Update of /cvsroot/radmind/radmind In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv1291 Modified Files: lcksum.c Log Message: [ Bug 1839610 ]: lcksum fails with -a and missing files. Restored -a functionality. Improved some error messages. Cleaned up some formatting. Index: lcksum.c =================================================================== RCS file: /cvsroot/radmind/radmind/lcksum.c,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** lcksum.c 1 Aug 2006 20:13:38 -0000 1.76 --- lcksum.c 2 Dec 2007 15:36:04 -0000 1.77 *************** *** 65,70 **** rr = read( afd, &header, AS_HEADERLEN ); if ( rr < 0 ) { ! perror( "read" ); ! exit( 2 ); } --- 65,70 ---- rr = read( afd, &header, AS_HEADERLEN ); if ( rr < 0 ) { ! fprintf( stderr, "%s: read failed: %s\n", applefile, strerror( errno )); ! return( -1 ); } *************** *** 78,83 **** rr = read( afd, &as_ents, ( 3 * sizeof( struct as_entry ))); if ( rr < 0 ) { ! perror( "read" ); ! exit( 2 ); } if ( rr != ( 3 * sizeof( struct as_entry ))) { --- 78,83 ---- rr = read( afd, &as_ents, ( 3 * sizeof( struct as_entry ))); if ( rr < 0 ) { ! fprintf( stderr, "%s: read failed: %s\n", applefile, strerror( errno )); ! return( -1 ); } if ( rr != ( 3 * sizeof( struct as_entry ))) { *************** *** 252,260 **** if (( tline[ len - 1 ] ) != '\n' ) { fprintf( stderr, "%s: %d: line too long\n", tpath, linenum); ! exitval = 1; ! goto done; } /* save transcript line -- must free */ ! if ( ( line = strdup( tline ) ) == NULL ) { perror( "strdup" ); cleanup( updatetran, upath ); --- 252,259 ---- if (( tline[ len - 1 ] ) != '\n' ) { fprintf( stderr, "%s: %d: line too long\n", tpath, linenum); ! goto badline; } /* save transcript line -- must free */ ! if (( line = strdup( tline )) == NULL ) { perror( "strdup" ); cleanup( updatetran, upath ); *************** *** 273,278 **** if ( tac == 1 ) { fprintf( stderr, "line %d: invalid transcript line\n", linenum ); ! exitval = 1; ! goto done; } --- 272,276 ---- if ( tac == 1 ) { fprintf( stderr, "line %d: invalid transcript line\n", linenum ); ! goto badline; } *************** *** 286,296 **** if (( d_path = decode( targv[ 1 ] )) == NULL ) { fprintf( stderr, "line %d: path too long\n", linenum ); ! exitval = 1; ! goto done; } if ( strlen( d_path ) >= MAXPATHLEN ) { fprintf( stderr, "line %d: path too long\n", linenum ); ! exitval = 1; ! goto done; } strcpy( path, d_path ); --- 284,292 ---- if (( d_path = decode( targv[ 1 ] )) == NULL ) { fprintf( stderr, "line %d: path too long\n", linenum ); ! goto badline; } if ( strlen( d_path ) >= MAXPATHLEN ) { fprintf( stderr, "line %d: path too long\n", linenum ); ! goto badline; } strcpy( path, d_path ); *************** *** 315,324 **** if ( prepath != 0 ) { if ( pathcasecmp( path, prepath, case_sensitive ) < 0 ) { ! if ( updatetran ) { ! fprintf( stderr, "line %d: bad sort order\n", linenum ); ! } else { ! fprintf( stderr, ! "line %d: bad sort order. Not continuing.\n", linenum ); ! } cleanup( updatetran, upath ); exit( 2 ); --- 311,315 ---- if ( prepath != 0 ) { if ( pathcasecmp( path, prepath, case_sensitive ) < 0 ) { ! fprintf( stderr, "line %d: bad sort order\n", linenum ); cleanup( updatetran, upath ); exit( 2 ); *************** *** 328,333 **** if ( strlen( path ) >= MAXPATHLEN ) { fprintf( stderr, "line %d: path too long\n", linenum ); ! exitval = 1; ! goto done; } strcpy( prepath, path ); --- 319,323 ---- if ( strlen( path ) >= MAXPATHLEN ) { fprintf( stderr, "line %d: path too long\n", linenum ); ! goto badline; } strcpy( prepath, path ); *************** *** 344,357 **** fprintf( stderr, "line %d: %d arguments should be 8\n", linenum, tac ); ! exitval = 1; ! goto done; } if ( snprintf( path, MAXPATHLEN, "%s/%s/%s", file_root, tran_name, ! d_path ) > MAXPATHLEN - 1 ) { fprintf( stderr, "%d: %s/%s/%s: path too long\n", linenum, file_root, tran_name, d_path ); ! exitval = 1; ! goto done; } --- 334,345 ---- fprintf( stderr, "line %d: %d arguments should be 8\n", linenum, tac ); ! goto badline; } if ( snprintf( path, MAXPATHLEN, "%s/%s/%s", file_root, tran_name, ! d_path ) >= MAXPATHLEN ) { fprintf( stderr, "%d: %s/%s/%s: path too long\n", linenum, file_root, tran_name, d_path ); ! goto badline; } *************** *** 369,388 **** /* open file here to save us some other open calls */ if (( fd = open( path, O_RDONLY, 0 )) < 0 ) { ! fprintf( stderr, "open %s: %s\n", d_path, strerror( errno )); ! cleanup( updatetran, upath ); ! exit( 2 ); } /* check size */ if ( fstat( fd, &st) != 0 ) { ! perror( path ); ! cleanup( updatetran, upath ); ! exit( 2 ); } if (( cksumsize = do_fcksum( fd, lcksum )) < 0 ) { ! perror( path ); ! cleanup( updatetran, upath ); ! exit( 2 ); } --- 357,376 ---- /* open file here to save us some other open calls */ if (( fd = open( path, O_RDONLY, 0 )) < 0 ) { ! fprintf( stderr, "line %d: open %s: %s\n", ! linenum, d_path, strerror( errno )); ! goto badline; } /* check size */ if ( fstat( fd, &st) != 0 ) { ! fprintf( stderr, "line %d: fstat failed: %s\n", ! linenum, strerror( errno )); ! goto badline; } if (( cksumsize = do_fcksum( fd, lcksum )) < 0 ) { ! fprintf( stderr, "line %d: %s: %s\n", linenum, ! path, strerror( errno )); ! goto badline; } *************** *** 418,436 **** /* rewind the descriptor */ if ( lseek( fd, 0, SEEK_SET ) < 0 ) { ! perror( "lseek" ); ! exitval = 1; ! goto done; } if ( ckapplefile( path, fd ) != st.st_size ) { fprintf( stderr, "%s: corrupted applefile\n", path ); ! exitval = 1; ! goto done; } } if ( close( fd ) != 0 ) { ! perror( "close" ); ! exitval = 1; ! goto done; } --- 406,424 ---- /* rewind the descriptor */ if ( lseek( fd, 0, SEEK_SET ) < 0 ) { ! fprintf( stderr, "%s: lseek failed: %s\n", ! path, strerror( errno )); ! goto badline; } if ( ckapplefile( path, fd ) != st.st_size ) { fprintf( stderr, "%s: corrupted applefile\n", path ); ! goto badline; } } if ( close( fd ) != 0 ) { ! /* unrecoverable error. can't leak descriptors. */ ! fprintf( stderr, "%s: close failed: %s\n", path, strerror( errno )); ! cleanup( updatetran, upath ); ! exit( 2 ); } *************** *** 498,501 **** --- 486,500 ---- } } + + /* this restores -a functionality. can't wait to replace lcksum. */ + badline: + exitval = 1; + + if ( checkall ) { + goto done; + } else { + cleanup( updatetran, upath ); + exit( 2 ); + } } |