<br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">shrims . .... ..</b> <span dir="ltr">&lt;<a href="mailto:shrims4u@gmail.com">shrims4u@gmail.com</a>&gt;</span><br>
Date: Fri, May 8, 2009 at 12:05 PM<br>Subject: segmentation error while using mpz_powm in a loop<br>To: <a href="mailto:gmp-bugs@gmplib.org">gmp-bugs@gmplib.org</a><br><br><br>I am getting segmentation fault in the program below.<br>
I have initialised all the GMP variables properly...<br>But still i am getting segmentation fault at  <b>mpz_powm( );<br></b>The loop runs only once and second time it gives segmentation fault at mpz_powm...<br>

<b><br>The code is as follows:<br><br></b><b>mpz_t bigbody,encbody,decbody,n,d,e;<br>
<br>
mpz_init(bigbody);<br>
mpz_init(decbody);<br>
<br>
while(i&lt;noOfBlocks)<br>
{        <br>
        <br>
        strncpy(substring, data_buffer + lower, upper);<br>
        *(substring+308)=&#39;\0&#39;;<br>
        <br>
        lower=upper;<br>
        upper=upper+308;<br>
        i++;<br>
<br>
        <br>
        mpz_set_str(bigbody,substring,10);<br>
<br>
        //size=len;<br>
<br>
        mpz_powm (decbody, bigbody, d, n);<br>
<br>
}<br><br><br>The again i tried to use arrays but this time the loop runs for 2 times and then gives segmentation fault...<br><br>The code is as follows..<br><br>mpz_t array[10];<br>//mpz_array_init (array, 10, 308);<br>mpz_t array1[10];<br>


//mpz_array_init (array1, 10, 308);<br><br>while(i&lt;noOfBlocks)<br>{<br>   strncpy(substring, data_buffer + lower, upper);<br>   lower=upper;<br>   upper=upper+308;<br>   mpz_init_set_str(array[i],substring,10);<br><br>


   mpz_get_str (STR, 10, array[i]);<br>   strcat(STR,&quot;\0&quot;);<br><br>    syslog( LOG_INFO, &quot;conn# %d - Encrypted-Biginteger = %s&quot;, cd-&gt;connection_num, STR );<br><br>    mpz_init(array1[i]);<br>    <br>


    mpz_powm (array1[i], array[i], d, n);<br>}<br><br></b>
</div><br>