Changeset 422
- Timestamp:
- 07/26/06 04:18:10
- Files:
-
- openpgpsdk/trunk/include/openpgpsdk/accumulate.h (modified) (1 diff)
- openpgpsdk/trunk/include/openpgpsdk/errors.h (modified) (1 diff)
- openpgpsdk/trunk/src/armour.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openpgpsdk/trunk/include/openpgpsdk/accumulate.h
r418 r422 4 4 #include "keyring.h" 5 5 6 int ops_parse_and_accumulate(ops_keyring_t *keyring,ops_parse_info_t *parse_info); 6 int ops_parse_and_accumulate(ops_keyring_t *keyring, 7 ops_parse_info_t *parse_info); openpgpsdk/trunk/include/openpgpsdk/errors.h
r336 r422 19 19 OPS_E_R_READ_FAILED =OPS_E_R+1, 20 20 OPS_E_R_EARLY_EOF =OPS_E_R+2, 21 OPS_E_R_BAD_FORMAT =OPS_E_R+3, // For example, malformed armour 21 22 22 23 /* writer errors */ openpgpsdk/trunk/src/armour.c
r417 r422 64 64 // FIXME: move these to a common header 65 65 #define CB(cbinfo,t,pc) do { (pc)->tag=(t); if(ops_parse_cb((pc),(cbinfo)) == OPS_RELEASE_MEMORY) ops_parser_content_free(pc); } while(0) 66 #define ERR(cbinfo,err ) do { content.content.error.error=err; content.tag=OPS_PARSER_ERROR; ops_parse_cb(&content,(cbinfo)); return -1; } while(0)66 #define ERR(cbinfo,err,code) do { content.content.error.error=err; content.tag=OPS_PARSER_ERROR; ops_parse_cb(&content,(cbinfo)); OPS_ERROR(errors,code,err); return -1; } while(0) 67 67 68 68 static void push_back(dearmour_arg_t *arg,const unsigned char *buf, … … 230 230 { 231 231 free(hash); 232 ERR(cbinfo,"Unknown hash algorithm" );232 ERR(cbinfo,"Unknown hash algorithm",OPS_E_R_BAD_FORMAT); 233 233 } 234 234 ops_hash_any(hash,alg); … … 256 256 /* then this had better be a trailer! */ 257 257 if(c != '-') 258 ERR(cbinfo,"Bad dash-escaping" );258 ERR(cbinfo,"Bad dash-escaping",OPS_E_R_BAD_FORMAT); 259 259 for(count=2 ; count < 5 ; ++count) 260 260 { … … 262 262 return -1; 263 263 if(c != '-') 264 ERR(cbinfo,"Bad dash-escaping (2)" );264 ERR(cbinfo,"Bad dash-escaping (2)",OPS_E_R_BAD_FORMAT); 265 265 } 266 266 arg->state=AT_TRAILER_NAME; … … 344 344 if(!first && !arg->allow_headers_without_gap) 345 345 // then we have seriously malformed armour 346 ERR(cbinfo,"No colon in armour header" );346 ERR(cbinfo,"No colon in armour header",OPS_E_R_BAD_FORMAT); 347 347 else 348 348 { 349 349 if(first && 350 350 !(arg->allow_headers_without_gap || arg->allow_no_gap)) 351 ERR(cbinfo,"No colon in armour header (2)"); 351 ERR(cbinfo,"No colon in armour header (2)", 352 OPS_E_R_BAD_FORMAT); 352 353 // then we have a nasty armoured block with no 353 354 // headers, not even a blank line. … … 360 361 *s='\0'; 361 362 if(s[1] != ' ') 362 ERR(cbinfo,"No space in armour header" );363 ERR(cbinfo,"No space in armour header",OPS_E_R_BAD_FORMAT); 363 364 add_header(arg,buf,s+2); 364 365 nbuf=0; … … 454 455 ret=read4(arg,errors,rinfo,cbinfo,&c,&n,&l); 455 456 if(ret < 0) 456 ERR(cbinfo,"Badly formed base64" );457 ERR(cbinfo,"Badly formed base64",OPS_E_R_BAD_FORMAT); 457 458 458 459 if(n == 3) … … 471 472 c=read_char(arg,errors,rinfo,cbinfo,ops_false); 472 473 if(c != '=') 473 ERR(cbinfo,"Badly terminated base64" );474 ERR(cbinfo,"Badly terminated base64",OPS_E_R_BAD_FORMAT); 474 475 } 475 476 else if(n == 0) … … 491 492 c=read_and_eat_whitespace(arg,errors,rinfo,cbinfo,ops_true); 492 493 if(c != '\n') 493 ERR(cbinfo,"No newline at base64 end" );494 ERR(cbinfo,"No newline at base64 end",OPS_E_R_BAD_FORMAT); 494 495 c=read_char(arg,errors,rinfo,cbinfo,ops_false); 495 496 if(c != '=') 496 ERR(cbinfo,"No checksum at base64 end" );497 ERR(cbinfo,"No checksum at base64 end",OPS_E_R_BAD_FORMAT); 497 498 } 498 499 … … 502 503 ret=read4(arg,errors,rinfo,cbinfo,&c,&n,&arg->read_checksum); 503 504 if(ret < 0 || n != 4) 504 ERR(cbinfo,"Error in checksum" );505 ERR(cbinfo,"Error in checksum",OPS_E_R_BAD_FORMAT); 505 506 c=read_char(arg,errors,rinfo,cbinfo,ops_true); 506 507 if(arg->allow_trailing_whitespace) 507 508 c=eat_whitespace(c,arg,errors,rinfo,cbinfo,ops_true); 508 509 if(c != '\n') 509 ERR(cbinfo,"Badly terminated checksum" );510 ERR(cbinfo,"Badly terminated checksum",OPS_E_R_BAD_FORMAT); 510 511 c=read_char(arg,errors,rinfo,cbinfo,ops_false); 511 512 if(c != '-') 512 ERR(cbinfo,"Bad base64 trailer (2)" );513 ERR(cbinfo,"Bad base64 trailer (2)",OPS_E_R_BAD_FORMAT); 513 514 } 514 515 … … 517 518 for(n=0 ; n < 4 ; ++n) 518 519 if(read_char(arg,errors,rinfo,cbinfo,ops_false) != '-') 519 ERR(cbinfo,"Bad base64 trailer" );520 ERR(cbinfo,"Bad base64 trailer",OPS_E_R_BAD_FORMAT); 520 521 arg->eof64=ops_true; 521 522 } … … 533 534 534 535 if(arg->eof64 && arg->read_checksum != arg->checksum) 535 ERR(cbinfo,"Checksum mismatch" );536 ERR(cbinfo,"Checksum mismatch",OPS_E_R_BAD_FORMAT); 536 537 537 538 return 1; … … 701 702 } 702 703 /* then I guess this wasn't a proper trailer */ 703 ERR(cbinfo,"Bad ASCII armour trailer" );704 ERR(cbinfo,"Bad ASCII armour trailer",OPS_E_R_BAD_FORMAT); 704 705 break; 705 706 … … 714 715 if(c != '-') 715 716 /* wasn't a trailer after all */ 716 ERR(cbinfo,"Bad ASCII armour trailer (2)"); 717 ERR(cbinfo,"Bad ASCII armour trailer (2)", 718 OPS_E_R_BAD_FORMAT); 717 719 } 718 720 … … 726 728 if(c != '\n') 727 729 /* wasn't a trailer line after all */ 728 ERR(cbinfo,"Bad ASCII armour trailer (3)" );730 ERR(cbinfo,"Bad ASCII armour trailer (3)",OPS_E_R_BAD_FORMAT); 729 731 730 732 if(!strncmp(buf,"BEGIN ",6))
