Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7622057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:21:23+00:00 2026-05-31T04:21:23+00:00

The following function gets file offsets from the rabin_polynomial structure, opens the input_file for

  • 0

The following function gets file offsets from the rabin_polynomial structure, opens the input_file for md5 fingerprint generation and writes the result to fpfile

My problem is it seems to use the same chunk_buffer content some times that it generates similar fingerprints for chunks with different legths.

What could be the reason?

I have tested the md5 function with other inputs separately and it generates correct digests.

   int write_rabin_fingerprints_to_binary_file(FILE *fpfile,FILE *input_file,
    struct rabin_polynomial *head)
{        
    struct rabin_polynomial *poly=head;
    unsigned char fing_print[33]={'\0'};
    size_t bytes_read;
      while(poly != NULL)
        {    
       char *chunk_buffer;
       chunk_buffer = (char*) malloc ((poly->length));  
       bytes_read=fread (chunk_buffer,1, poly->length,input_file);          
               if(bytes_read!=poly->length)
                {
                   printf("Error reading from%s ",input_file);
                   return -1;
                }
       strncpy((char*)fing_print,md5(chunk_buffer).c_str(),32);     
       size_t ret_val=fprintf(fpfile, "%llu\t%lu\t%s\n",poly->start,
                                       poly->length,fing_print);

              if(ret_val == 0)
               {
                  fprintf(stderr, "Could not write rabin polynomials to file.");
                  return -1;
               }

         poly=poly->next_polynomial;
      free(chunk_buffer);
        }

   return 0;
}

EDIT:

I am running this program using visual studio 2010. Could typecasting to char * in the malloc() line create the problem?

The number of bytes read is just as specified in the argument.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:21:25+00:00Added an answer on May 31, 2026 at 4:21 am

    There was nothing wrong in the code to cause such faults. I just found out that it happened because of zero-length strings which are also called as file holes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following function that is pulling data from a database. The ajax
So: I have the following function, adapted from a formula found online, which takes
I have the following function, which returns a filesize of a file over HTTP:
From my jQuery file, I call a function from my controller which returns a
I am using nodejs. And calling something like the following from a javascript file:
I am new to JQuery and I have the following issue: Source file: function
I am exporting a function from vc++ DLL to write to a binary file.
I have the following code: function drawDimensions(divid) { // This function gets a JSON
I'm trying to write a function that gets a path and returns this file's
I have the following structure and function that adds things to the structure: struct

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.