@@ -206,7 +206,7 @@ static u_char *cab_digest_calc(FILE_FORMAT_CTX *ctx, const EVP_MD *md)
206206 BIO * bhash = BIO_new (BIO_f_md ());
207207
208208 if (!BIO_set_md (bhash , md )) {
209- printf ( "Unable to set the message digest of BIO\n" );
209+ fprintf ( stderr , "Unable to set the message digest of BIO\n" );
210210 BIO_free_all (bhash );
211211 return 0 ; /* FAILED */
212212 }
@@ -296,7 +296,7 @@ static u_char *cab_digest_calc(FILE_FORMAT_CTX *ctx, const EVP_MD *md)
296296 nfolders -- ;
297297 }
298298 if (idx != coffFiles ) {
299- printf ( "Corrupt coffFiles value: 0x%08X\n" , coffFiles );
299+ fprintf ( stderr , "Corrupt coffFiles value: 0x%08X\n" , coffFiles );
300300 BIO_free_all (bhash );
301301 return 0 ; /* FAILED */
302302 }
@@ -307,7 +307,7 @@ static u_char *cab_digest_calc(FILE_FORMAT_CTX *ctx, const EVP_MD *md)
307307 }
308308 /* (variable) ab - the compressed data bytes */
309309 if (!bio_hash_data (bhash , ctx -> options -> indata , idx , fileend )) {
310- printf ( "Unable to calculate digest\n" );
310+ fprintf ( stderr , "Unable to calculate digest\n" );
311311 BIO_free_all (bhash );
312312 return 0 ; /* FAILED */
313313 }
@@ -343,17 +343,17 @@ static int cab_verify_digests(FILE_FORMAT_CTX *ctx, PKCS7 *p7)
343343 }
344344 }
345345 if (mdtype == -1 ) {
346- printf ( "Failed to extract current message digest\n\n" );
346+ fprintf ( stderr , "Failed to extract current message digest\n\n" );
347347 return 0 ; /* FAILED */
348348 }
349349 md = EVP_get_digestbynid (mdtype );
350350 cmdbuf = cab_digest_calc (ctx , md );
351351 if (!cmdbuf ) {
352- printf ( "Failed to calculate message digest\n\n" );
352+ fprintf ( stderr , "Failed to calculate message digest\n\n" );
353353 return 0 ; /* FAILED */
354354 }
355355 if (!compare_digests (mdbuf , cmdbuf , mdtype )) {
356- printf ( "Signature verification: failed\n\n" );
356+ fprintf ( stderr , "Signature verification: failed\n\n" );
357357 OPENSSL_free (cmdbuf );
358358 return 0 ; /* FAILED */
359359 }
@@ -443,7 +443,7 @@ static int cab_remove_pkcs7(FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata)
443443 BIO_write (outdata , ctx -> options -> indata + 32 , 4 );
444444 idx = cab_write_optional_names (outdata , ctx -> options -> indata , 60 , flags );
445445 if (idx >= ctx -> cab_ctx -> fileend ) {
446- printf ( "Corrupt CAB file - too short\n" );
446+ fprintf ( stderr , "Corrupt CAB file - too short\n" );
447447 OPENSSL_free (buf );
448448 return 0 ; /* FAILED */
449449 }
@@ -453,7 +453,7 @@ static int cab_remove_pkcs7(FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata)
453453 */
454454 nfolders = GET_UINT16_LE (ctx -> options -> indata + 26 );
455455 if (nfolders * 8 >= ctx -> cab_ctx -> fileend - idx ) {
456- printf ( "Corrupt cFolders value: 0x%08X\n" , nfolders );
456+ fprintf ( stderr , "Corrupt cFolders value: 0x%08X\n" , nfolders );
457457 OPENSSL_free (buf );
458458 return 0 ; /* FAILED */
459459 }
@@ -510,26 +510,26 @@ static PKCS7 *cab_pkcs7_signature_new(FILE_FORMAT_CTX *ctx, BIO *hash)
510510 PKCS7 * p7 = pkcs7_create (ctx );
511511
512512 if (!p7 ) {
513- printf ( "Creating a new signature failed\n" );
513+ fprintf ( stderr , "Creating a new signature failed\n" );
514514 return NULL ; /* FAILED */
515515 }
516516 if (ctx -> options -> jp >= 0 && !cab_add_jp_attribute (p7 , ctx -> options -> jp )) {
517- printf ( "Adding jp attribute failed\n" );
517+ fprintf ( stderr , "Adding jp attribute failed\n" );
518518 PKCS7_free (p7 );
519519 return NULL ; /* FAILED */
520520 }
521521 if (!add_indirect_data_object (p7 )) {
522- printf ( "Adding SPC_INDIRECT_DATA_OBJID failed\n" );
522+ fprintf ( stderr , "Adding SPC_INDIRECT_DATA_OBJID failed\n" );
523523 PKCS7_free (p7 );
524524 return NULL ; /* FAILED */
525525 }
526526 content = spc_indirect_data_content_get (hash , ctx );
527527 if (!content ) {
528- printf ( "Failed to get spcIndirectDataContent\n" );
528+ fprintf ( stderr , "Failed to get spcIndirectDataContent\n" );
529529 return NULL ; /* FAILED */
530530 }
531531 if (!sign_spc_indirect_data_content (p7 , content )) {
532- printf ( "Failed to set signed content\n" );
532+ fprintf ( stderr , "Failed to set signed content\n" );
533533 PKCS7_free (p7 );
534534 ASN1_OCTET_STRING_free (content );
535535 return NULL ; /* FAILED */
@@ -556,7 +556,7 @@ static int cab_append_pkcs7(FILE_FORMAT_CTX *ctx, BIO *outdata, PKCS7 *p7)
556556
557557 if (((len = i2d_PKCS7 (p7 , NULL )) <= 0 )
558558 || (p = OPENSSL_malloc ((size_t )len )) == NULL ) {
559- printf ( "i2d_PKCS memory allocation failed: %d\n" , len );
559+ fprintf ( stderr , "i2d_PKCS memory allocation failed: %d\n" , len );
560560 return 1 ; /* FAILED */
561561 }
562562 i2d_PKCS7 (p7 , & p );
@@ -653,19 +653,19 @@ static CAB_CTX *cab_ctx_get(char *indata, uint32_t filesize)
653653 uint16_t flags ;
654654
655655 if (filesize < 44 ) {
656- printf ( "CAB file is too short\n" );
656+ fprintf ( stderr , "CAB file is too short\n" );
657657 return NULL ; /* FAILED */
658658 }
659659 reserved = GET_UINT32_LE (indata + 4 );
660660 if (reserved ) {
661- printf ( "Reserved1: 0x%08X\n" , reserved );
661+ fprintf ( stderr , "Reserved1: 0x%08X\n" , reserved );
662662 return NULL ; /* FAILED */
663663 }
664664 /* flags specify bit-mapped values that indicate the presence of optional data */
665665 flags = GET_UINT16_LE (indata + 30 );
666666 if (flags & FLAG_PREV_CABINET ) {
667667 /* FLAG_NEXT_CABINET works */
668- printf ( "Multivolume cabinet file is unsupported: flags 0x%04X\n" , flags );
668+ fprintf ( stderr , "Multivolume cabinet file is unsupported: flags 0x%04X\n" , flags );
669669 return NULL ; /* FAILED */
670670 }
671671 if (flags & FLAG_RESERVE_PRESENT ) {
@@ -675,12 +675,12 @@ static CAB_CTX *cab_ctx_get(char *indata, uint32_t filesize)
675675 */
676676 header_size = GET_UINT32_LE (indata + 36 );
677677 if (header_size != 20 ) {
678- printf ( "Additional header size: 0x%08X\n" , header_size );
678+ fprintf ( stderr , "Additional header size: 0x%08X\n" , header_size );
679679 return NULL ; /* FAILED */
680680 }
681681 reserved = GET_UINT32_LE (indata + 40 );
682682 if (reserved != 0x00100000 ) {
683- printf ( "abReserved: 0x%08X\n" , reserved );
683+ fprintf ( stderr , "abReserved: 0x%08X\n" , reserved );
684684 return NULL ; /* FAILED */
685685 }
686686 /*
@@ -695,13 +695,13 @@ static CAB_CTX *cab_ctx_get(char *indata, uint32_t filesize)
695695 sigpos = GET_UINT32_LE (indata + 44 );
696696 siglen = GET_UINT32_LE (indata + 48 );
697697 if ((sigpos < filesize && sigpos + siglen != filesize ) || (sigpos >= filesize )) {
698- printf ( "Additional data offset:\t%u bytes\nAdditional data size:\t%u bytes\n" ,
698+ fprintf ( stderr , "Additional data offset:\t%u bytes\nAdditional data size:\t%u bytes\n" ,
699699 sigpos , siglen );
700- printf ( "File size:\t\t%u bytes\n" , filesize );
700+ fprintf ( stderr , "File size:\t\t%u bytes\n" , filesize );
701701 return NULL ; /* FAILED */
702702 }
703703 if ((sigpos > 0 && siglen == 0 ) || (sigpos == 0 && siglen > 0 )) {
704- printf ( "Corrupt signature\n" );
704+ fprintf ( stderr , "Corrupt signature\n" );
705705 return NULL ; /* FAILED */
706706 }
707707 }
@@ -852,7 +852,7 @@ static int cab_modify_header(FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata)
852852
853853 idx = cab_write_optional_names (outdata , ctx -> options -> indata , 60 , flags );
854854 if (idx >= ctx -> cab_ctx -> fileend ) {
855- printf ( "Corrupt CAB file - too short\n" );
855+ fprintf ( stderr , "Corrupt CAB file - too short\n" );
856856 return 0 ; /* FAILED */
857857 }
858858 /*
@@ -861,7 +861,7 @@ static int cab_modify_header(FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata)
861861 */
862862 nfolders = GET_UINT16_LE (ctx -> options -> indata + 26 );
863863 if (nfolders * 8 >= ctx -> cab_ctx -> fileend - idx ) {
864- printf ( "Corrupt cFolders value: 0x%08X\n" , nfolders );
864+ fprintf ( stderr , "Corrupt cFolders value: 0x%08X\n" , nfolders );
865865 return 0 ; /* FAILED */
866866 }
867867 while (nfolders ) {
@@ -936,7 +936,7 @@ static int cab_add_header(FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata)
936936
937937 idx = cab_write_optional_names (outdata , ctx -> options -> indata , 36 , flags );
938938 if (idx >= ctx -> cab_ctx -> fileend ) {
939- printf ( "Corrupt CAB file - too short\n" );
939+ fprintf ( stderr , "Corrupt CAB file - too short\n" );
940940 OPENSSL_free (buf );
941941 return 0 ; /* FAILED */
942942 }
@@ -946,7 +946,7 @@ static int cab_add_header(FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata)
946946 */
947947 nfolders = GET_UINT16_LE (ctx -> options -> indata + 26 );
948948 if (nfolders * 8 >= ctx -> cab_ctx -> fileend - idx ) {
949- printf ( "Corrupt cFolders value: 0x%08X\n" , nfolders );
949+ fprintf ( stderr , "Corrupt cFolders value: 0x%08X\n" , nfolders );
950950 OPENSSL_free (buf );
951951 return 0 ; /* FAILED */
952952 }
@@ -979,16 +979,16 @@ static int cab_add_header(FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata)
979979static int cab_check_file (FILE_FORMAT_CTX * ctx )
980980{
981981 if (!ctx ) {
982- printf ( "Init error\n \n" );
982+ fprintf ( stderr , "Init error\n" );
983983 return 0 ; /* FAILED */
984984 }
985985 if (ctx -> cab_ctx -> header_size != 20 ) {
986- printf ( "No signature found\n \n" );
986+ fprintf ( stderr , "No signature found\n" );
987987 return 0 ; /* FAILED */
988988 }
989989 if (ctx -> cab_ctx -> sigpos == 0 || ctx -> cab_ctx -> siglen == 0
990990 || ctx -> cab_ctx -> sigpos > ctx -> cab_ctx -> fileend ) {
991- printf ( "No signature found\n \n" );
991+ fprintf ( stderr , "No signature found\n" );
992992 return 0 ; /* FAILED */
993993 }
994994 return 1 ; /* OK */
0 commit comments