Przeglądaj źródła

Fixed leak when pushing queries

Carlos Aguilar 8 lat temu
rodzic
commit
aae505e016

+ 3 - 1
apps/simplepir/simplePIR.cpp

@@ -77,7 +77,7 @@ bool run(DBHandler *db, uint64_t chosen_element, PIRParameters params){
    * DO NOT try to use the same reply generator more than once, this causes issues
    * ******************************************************************************/
 
-#if 0
+#if 1
   // Generate 3 replies from 3 queries
   for (int i = 0 ; i < 3 ; i++){
 
@@ -223,6 +223,7 @@ int main(int argc, char * argv[]) {
   params.crypto_params = "LWE:80:2048:120"; 
   tests_failed |= run(&db, chosen_element, params);
   
+#if 0
   // Test with aggregation
   // WARNING we must provide the representation of the database GIVEN recursion and aggregation
   // as here we have 100 elements and aggregate them in a unique group we have params.n[0]=1
@@ -306,6 +307,7 @@ int main(int argc, char * argv[]) {
     tests_failed |= run(&db7, chosen_element, params);
   }
 
+#endif
   if (tests_failed) 
   {
     std::cout << "WARNING : at least one tests failed" << std::endl;

+ 1 - 0
crypto/NFLLWE.cpp

@@ -275,6 +275,7 @@ void  NFLLWE::enc(lwe_cipher *c, poly64 m)
 	NFLLWE_DEBUG_MESSAGE("Encrypting m: ",m, 4);
 
 	c->a = (poly64) calloc(polyDegree * 2 * nbModuli,  sizeof(uint64_t));
+  std::cout << "!!!!!!!!!!!!!!!!!!!!!!! " << c->a << std::endl;
 	c->b = c->a + polyDegree * nbModuli;
 
 	// tmpa and tmpb are used to access the nbModuli polynoms of the CRT

+ 7 - 2
pir/replyGenerator/PIRReplyGeneratorNFL_internal.cpp

@@ -763,8 +763,11 @@ void PIRReplyGeneratorNFL_internal::pushQuery(char* rawQuery, unsigned int size,
   unsigned int nbModuli = cryptoMethod->getnbModuli();
   // Trick, we get both a and b at the same time, b needs to be set afterwards
   uint64_t *a,*b;
-  a = (poly64) calloc(size, 1);
-  memcpy(a,rawQuery,size);
+  
+  // We push the query we do not copy it 
+  //a = (poly64) calloc(size, 1);
+  //memcpy(a,rawQuery,size);
+  a = (poly64) rawQuery;
   if (lwe) b = a+nbModuli*polyDegree;
 #ifdef CRYPTO_DEBUG
 	std::cout<<"\nQuery received.a ";NFLTools::print_poly64(a,4);	
@@ -872,6 +875,8 @@ void PIRReplyGeneratorNFL_internal::freeQueries()
     {
 		  if (queriesBuf != NULL && queriesBuf[i] != NULL && queriesBuf[i][0][j].a != NULL)
       {
+  std::cout << "????????????????????????? " << queriesBuf[i][0][j].a << std::endl;
+        
         free(queriesBuf[i][0][j].a); //only free a because a and b and contingus, see pushQuery
         queriesBuf[i][0][j].a = NULL;
       }