Changeset 549

Show
Ignore:
Timestamp:
03/23/07 17:55:13 (2 years ago)
Author:
sacha
Message:

variable was not initialized and hence caused a segmentation fault on 32bit.
the variable was actually not even used and is now removed.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src-c/xmldsig-signing-ebXML-user-message/hefeweizen_sign_ebXML_user_message.c

    r445 r549  
    119119int replace_soap_header(const char* multipart_mime_file, xmlChar* signed_soap_mem, const char* output_file_name); 
    120120int replace_soap_header_y(const char* multipart_mime_file, const char* temp_output_file_name, const char* output_file_name); 
    121 int replace_soap_header_x(const char* original_multipart_mime_file, const char* signed_soap_file_name, const char* final_output_file_name); 
    122121 
    123122/** 
     
    150149 
    151150void* cidOpenFunction_real(const char* filename){ 
    152   char* content_id = NULL; 
     151  const char* content_id = NULL; 
    153152 
    154153  if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "cid:", 4)) { 
     
    448447  GMimePart* soap = (GMimePart*) g_mime_multipart_get_part(multipart, 0); 
    449448   
     449  fprintf(stdout, "Before strln: replace_soap_header"); 
    450450  g_mime_part_set_content(soap, (char*)signed_soap_mem, strlen(signed_soap_mem)); 
    451451  //  g_mime_multipart_set_boundary(multipart, "dddddddddddddddddddddddddd^M"); 
     
    518518 
    519519  fprintf(stdout, "HHHHHHHHHHHHHHHELO\n"); 
    520   fprintf(stdout, "HHHHHHHHHHHHHHHELO\n"); 
    521   fprintf(stdout, "HHHHHHHHHHHHHHHELO\n"); 
    522   fprintf(stdout, "HHHHHHHHHHHHHHHELO\n"); 
    523   fprintf(stdout, "HHHHHHHHHHHHHHHELO\n"); 
    524   fprintf(stdout, "HHHHHHHHHHHHHHHELO\n"); 
    525  
     520  fprintf(stdout, "Before strlen: replace soap header_y"); 
    526521  g_mime_part_set_content(soap, buffer, strlen(buffer)); 
    527522 
     
    548543} 
    549544 
    550 int replace_soap_header_x(const char* original_multipart_mime_file, const char* signed_soap_file_name, const char* final_output_file_name){ 
    551   GMimeMessage* message; 
    552   int fd; 
    553  
    554   if ((fd = open (multipart_mime_file, O_RDONLY)) == -1) { 
    555     fprintf (stderr, "Cannot open message `%s': %s to write soap message.\n", multipart_mime_file, strerror (errno)); 
    556     //    return -1; 
    557   } 
    558    
    559   message = parse_message(fd); 
    560   close(fd); 
    561  
    562   GMimeObject* part = NULL; 
    563   part = g_mime_message_get_mime_part(message); 
    564   GMimeMultipart* multipart = (GMimeMultipart*) part; 
    565  
    566  
    567   g_mime_multipart_remove_part_at(multipart, 0); 
    568    
    569   /* create the new part that we are going to add... */ 
    570   GMimePart *mime_part; 
    571   mime_part = g_mime_part_new_with_type ("text", "xml"); 
    572   g_mime_part_set_encoding(mime_part, GMIME_PART_ENCODING_BINARY); 
    573    
    574  
    575   fprintf(stdout, "HHHHHHHHHHHHHHHELO\n"); 
    576   fprintf(stdout, "HHHHHHHHHHHHHHHELO\n"); 
    577   fprintf(stdout, "HHHHHHHHHHHHHHHELO\n"); 
    578    
    579   FILE * pFile; 
    580   long lSize; 
    581   char * buffer; 
    582   size_t result; 
    583  
    584   pFile = fopen ( signed_soap_file_name , "rb" ); 
    585   if (pFile==NULL) {fputs ("File error",stderr); return (-1);} 
    586  
    587   // obtain file size: 
    588   fseek (pFile , 0 , SEEK_END); 
    589   lSize = ftell (pFile); 
    590   rewind (pFile); 
    591  
    592   // allocate memory to contain the whole file: 
    593   buffer = (char*) malloc (sizeof(char)*lSize); 
    594   if (buffer == NULL) {fputs ("Memory error",stderr); return (-2);} 
    595  
    596   // copy the file into the buffer: 
    597   result = fread (buffer,1,lSize,pFile); 
    598   if (result != lSize) {fputs ("Reading error",stderr); return (-3);} 
    599  
    600   /* the whole file is now loaded in the memory buffer. */ 
    601    
    602   //  fprintf(stdout, "Signed shitr: %s\n", buffer); 
    603  
    604   //  return(0); 
    605  
    606   g_mime_part_set_content (mime_part, buffer, strlen(buffer)); 
    607  
    608  
    609   g_mime_multipart_add_part_at(multipart, mime_part, 0); 
    610  
    611   char* text; 
    612   text = g_mime_message_to_string (message); 
    613  
    614   FILE* output_file = NULL; 
    615   //  char* file_name = "/tmp/final_output_soap_file"; 
    616   if ((output_file = fopen(final_output_file_name, "w")) == NULL) 
    617     fprintf(stderr, "Cannot open %s to write soap message.\n", final_output_file_name); 
    618   fprintf(output_file, "%s", text); 
    619   fclose(output_file); 
    620  
    621   g_free (text); 
    622   g_mime_object_unref (GMIME_OBJECT (message)); 
    623  
    624   // terminate 
    625   fclose (pFile); 
    626   free (buffer); 
    627   return 0; 
    628    
    629 } 
    630545 
    631546static void  
    632547foreach_callback_payload(GMimeObject *part, gpointer user_data) 
    633548{ 
     549 
    634550  const char* content_id = NULL; 
    635551  int compare; 
    636   GMimeDataWrapper *content; 
    637   const char *filename; 
    638   GMimeStream *stream; 
     552  GMimeDataWrapper* content =NULL; 
     553  GMimeStream *stream = NULL; 
    639554  int fd2; 
    640555 
     556  if (debug == 1){ 
     557    fprintf(stdout, "Getting content id of given mime part"); 
     558  } 
    641559  content_id = g_mime_part_get_content_id((GMimePart *)part); 
    642560 
     
    644562    return; 
    645563  } 
     564   
     565  if (debug == 1) 
     566    fprintf(stdout, "The content id is '%s' .\n", content_id ); 
    646567 
    647568  /* lets see if this is the required content id */ 
     
    653574    } 
    654575     
    655     if (debug == 1){ 
    656       fprintf(stdout, "The file name for the mime part with id '%s' is '%s'.\n", content_id, filename ); 
    657     } 
    658576    //    if ((fd2 = open (filename, O_CREAT | O_WRONLY, 0666)) == -1) { 
    659577    if ((fd2 = open (payload_message_filename, O_CREAT | O_WRONLY | O_TRUNC, 0666)) == -1) { 
     
    712630    fprintf(stdout, "new filename %s\n", payload_message_filename); 
    713631 
     632  //nnnnnnnnnnnnnnnnnnnnnn 
     633  fprintf(stdout, "Message %s", message); 
    714634 
    715635  g_mime_message_foreach_part (message, foreach_callback_payload, &count); 
  • trunk/src-c/xmldsig-validate-signature-ebXML-user-message/hefeweizen_validate_signature_ebXML_user_message.c

    r426 r549  
    6969char* file_path; 
    7070 
    71  
    7271char* get_temp_filename(); 
    7372void set_root_path(); 
     
    111110 
    112111void* cidOpenFunction_real(const char* filename){ 
    113   char* content_id = NULL; 
     112  const char* content_id = NULL; 
    114113 
    115114  if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "cid:", 4)) { 
    116115 
     116    content_id = &filename[4]; 
     117    /* 
    117118#if defined (_WIN32) || defined (__DJGPP__) && !defined(__CYGWIN__) 
    118119    content_id = &filename[5]; 
     
    120121    content_id = &filename[4]; 
    121122#endif 
     123    */ 
    122124  } else  
    123125    content_id = filename; 
     
    529531  int compare; 
    530532  GMimeDataWrapper *content; 
    531   const char *filename; 
    532533  GMimeStream *stream; 
    533534  int fd2; 
     
    537538  if (content_id == NULL) { 
    538539    return; 
     540  } 
     541 
     542  if (debug == 1){ 
     543    fprintf(stdout, "The content id is '%s'.\n", content_id ); 
    539544  } 
    540545 
     
    547552    } 
    548553     
    549     if (debug == 1){ 
    550       fprintf(stdout, "The file name for the mime part with id '%s' is '%s'.\n", content_id, filename ); 
    551     } 
    552554    //    if ((fd2 = open (filename, O_CREAT | O_WRONLY, 0666)) == -1) { 
    553555    if ((fd2 = open (payload_message_filename, O_CREAT | O_WRONLY | O_TRUNC, 0666)) == -1) {