Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
change some sprintf into snprintf
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 28 May 2016 21:09:57 +0000 (23:09 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 28 May 2016 21:09:57 +0000 (23:09 +0200)
examples/msg/actions-storage/actions-storage.c
examples/msg/app-bittorrent/peer.c
examples/msg/app-masterworker/app-masterworker.c
examples/msg/app-token-ring/app-token-ring.c
examples/msg/async-wait/async-wait.c
examples/msg/async-waitall/async-waitall.c
examples/msg/async-waitany/async-waitany.c
src/xbt/dynar.c

index 2be369d..76d399a 100644 (file)
@@ -30,7 +30,7 @@ static msg_file_t get_file_descriptor(const char *file_name){
   char full_name[1024];
   msg_file_t file = NULL;
 
   char full_name[1024];
   msg_file_t file = NULL;
 
-  sprintf(full_name, "%s:%s", MSG_process_get_name(MSG_process_self()), file_name);
+  snprintf(full_name,1023, "%s:%s", MSG_process_get_name(MSG_process_self()), file_name);
 
   file = (msg_file_t) xbt_dict_get_or_null(opened_files, full_name);
   return file;
 
   file = (msg_file_t) xbt_dict_get_or_null(opened_files, full_name);
   return file;
@@ -52,7 +52,7 @@ static void action_open(const char *const *action) {
   msg_file_t file = NULL;
   double clock = MSG_get_clock();
 
   msg_file_t file = NULL;
   double clock = MSG_get_clock();
 
-  sprintf(full_name, "%s:%s", MSG_process_get_name(MSG_process_self()), file_name);
+  snprintf(full_name,1023, "%s:%s", MSG_process_get_name(MSG_process_self()), file_name);
 
   ACT_DEBUG("Entering Open: %s (filename: %s)", NAME, file_name);
   file = MSG_file_open(file_name, NULL);
 
   ACT_DEBUG("Entering Open: %s (filename: %s)", NAME, file_name);
   file = MSG_file_open(file_name, NULL);
index 0ef1d35..9469fab 100644 (file)
@@ -204,8 +204,8 @@ int get_peers_data(peer_t peer)
 void peer_init(peer_t peer, int id, int seed)
 {
   peer->id = id;
 void peer_init(peer_t peer, int id, int seed)
 {
   peer->id = id;
-  sprintf(peer->mailbox, "%d", id);
-  sprintf(peer->mailbox_tracker, "tracker_%d", id);
+  snprintf(peer->mailbox,MAILBOX_SIZE-1, "%d", id);
+  snprintf(peer->mailbox_tracker,MAILBOX_SIZE-1, "tracker_%d", id);
   peer->peers = xbt_dict_new();
   peer->active_peers = xbt_dict_new();
   peer->hostname = MSG_host_get_name(MSG_host_self());
   peer->peers = xbt_dict_new();
   peer->active_peers = xbt_dict_new();
   peer->hostname = MSG_host_get_name(MSG_host_self());
index 0640633..899253d 100644 (file)
@@ -24,8 +24,8 @@ static int master(int argc, char *argv[])
     char mailbox[256];
     char task_name[256];
 
     char mailbox[256];
     char task_name[256];
 
-    sprintf(mailbox, "worker-%ld", i % workers_count); /* - Select a @ref worker in a round-robin way */
-    sprintf(task_name, "Task_%d", i);
+    snprintf(mailbox,255, "worker-%ld", i % workers_count); /* - Select a @ref worker in a round-robin way */
+    snprintf(task_name,255, "Task_%d", i);
     msg_task_t task = MSG_task_create(task_name, comp_size, comm_size, NULL);   /* - Create a task */
     if (number_of_tasks < 10000 || i % 10000 == 0)
       XBT_INFO("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name, number_of_tasks, mailbox);
     msg_task_t task = MSG_task_create(task_name, comp_size, comm_size, NULL);   /* - Create a task */
     if (number_of_tasks < 10000 || i % 10000 == 0)
       XBT_INFO("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name, number_of_tasks, mailbox);
@@ -37,7 +37,7 @@ static int master(int argc, char *argv[])
   for (i = 0; i < workers_count; i++) { /* - Eventually tell all the workers to stop by sending a "finalize" task */
     char mailbox[80];
 
   for (i = 0; i < workers_count; i++) { /* - Eventually tell all the workers to stop by sending a "finalize" task */
     char mailbox[80];
 
-    sprintf(mailbox, "worker-%ld", i % workers_count);
+    snprintf(mailbox,79, "worker-%ld", i % workers_count);
     msg_task_t finalize = MSG_task_create("finalize", 0, 0, 0);
     MSG_task_send(finalize, mailbox);
   }
     msg_task_t finalize = MSG_task_create("finalize", 0, 0, 0);
     MSG_task_send(finalize, mailbox);
   }
@@ -53,7 +53,7 @@ static int worker(int argc, char *argv[])
 
   long id= xbt_str_parse_int(argv[1], "Invalid argument %s");
 
 
   long id= xbt_str_parse_int(argv[1], "Invalid argument %s");
 
-  sprintf(mailbox, "worker-%ld", id);
+  snprintf(mailbox,79, "worker-%ld", id);
 
   while (1) {  /* The worker wait in an infinite loop for tasks sent by the \ref master */
     int res = MSG_task_receive(&(task), mailbox);
 
   while (1) {  /* The worker wait in an infinite loop for tasks sent by the \ref master */
     int res = MSG_task_receive(&(task), mailbox);
index abe1691..858889e 100644 (file)
@@ -16,7 +16,7 @@ static int foo(int argc, char *argv[])
   msg_task_t task = NULL;
   XBT_ATTRIB_UNUSED int res;
   if (rank == 0){ /* - The root (rank 0) first sends the token then waits to receive it back */
   msg_task_t task = NULL;
   XBT_ATTRIB_UNUSED int res;
   if (rank == 0){ /* - The root (rank 0) first sends the token then waits to receive it back */
-    sprintf(mailbox, "%d", rank+1);
+    snprintf(mailbox,255, "%d", rank+1);
     task = MSG_task_create("Token", 0, task_comm_size, NULL);
     XBT_INFO("Host \"%d\" send '%s' to Host \"%s\"", rank, task->name,mailbox);
     MSG_task_send(task, mailbox);
     task = MSG_task_create("Token", 0, task_comm_size, NULL);
     XBT_INFO("Host \"%d\" send '%s' to Host \"%s\"", rank, task->name,mailbox);
     MSG_task_send(task, mailbox);
@@ -31,9 +31,9 @@ static int foo(int argc, char *argv[])
     XBT_INFO("Host \"%d\" received \"%s\"",rank, MSG_task_get_name(task));
 
     if(rank+1 == MSG_get_host_number()) /* - Except for the last one which sends the token back to rank 0 */
     XBT_INFO("Host \"%d\" received \"%s\"",rank, MSG_task_get_name(task));
 
     if(rank+1 == MSG_get_host_number()) /* - Except for the last one which sends the token back to rank 0 */
-      sprintf(mailbox, "0");
+      snprintf(mailbox,255, "0");
     else
     else
-      sprintf(mailbox, "%d", rank+1);
+      snprintf(mailbox,255, "%d", rank+1);
     XBT_INFO("Host \"%d\" send '%s' to Host \"%s\"",rank,task->name,mailbox);
     MSG_task_send(task, mailbox);
   }
     XBT_INFO("Host \"%d\" send '%s' to Host \"%s\"",rank,task->name,mailbox);
     MSG_task_send(task, mailbox);
   }
index da753e8..814411a 100644 (file)
@@ -25,13 +25,13 @@ static int sender(int argc, char *argv[])
   MSG_process_sleep(sleep_start_time);
   for (i = 0; i < number_of_tasks; i++) {
     char mailbox[256];
   MSG_process_sleep(sleep_start_time);
   for (i = 0; i < number_of_tasks; i++) {
     char mailbox[256];
-    char sprintf_buffer[256];
+    char snprintf_buffer[256];
 
 
-    sprintf(mailbox, "receiver-%ld", i % receivers_count);
-    sprintf(sprintf_buffer, "Task_%d", i);
+    snprintf(mailbox,255, "receiver-%ld", i % receivers_count);
+    snprintf(snprintf_buffer,255, "Task_%d", i);
 
     /* This process first creates a task and send it asynchronously with @ref MSG_task_isend. Then, if: */
 
     /* This process first creates a task and send it asynchronously with @ref MSG_task_isend. Then, if: */
-    task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL);
+    task = MSG_task_create(snprintf_buffer, task_comp_size, task_comm_size, NULL);
     comm = MSG_task_isend(task, mailbox);
     XBT_INFO("Send to receiver-%ld Task_%d", i % receivers_count, i);
 
     comm = MSG_task_isend(task, mailbox);
     XBT_INFO("Send to receiver-%ld Task_%d", i % receivers_count, i);
 
@@ -47,7 +47,7 @@ static int sender(int argc, char *argv[])
 
   for (i = 0; i < receivers_count; i++) {
     char mailbox[80];
 
   for (i = 0; i < receivers_count; i++) {
     char mailbox[80];
-    sprintf(mailbox, "receiver-%ld", i % receivers_count);
+    snprintf(mailbox,79, "receiver-%ld", i % receivers_count);
     task = MSG_task_create("finalize", 0, 0, 0);
     comm = MSG_task_isend(task, mailbox);
     XBT_INFO("Send to receiver-%ld finalize", i % receivers_count);
     task = MSG_task_create("finalize", 0, 0, 0);
     comm = MSG_task_isend(task, mailbox);
     XBT_INFO("Send to receiver-%ld finalize", i % receivers_count);
@@ -79,7 +79,7 @@ static int receiver(int argc, char *argv[])
 
   MSG_process_sleep(sleep_start_time); /* This process first sleeps for "start time" seconds.  */
 
 
   MSG_process_sleep(sleep_start_time); /* This process first sleeps for "start time" seconds.  */
 
-  sprintf(mailbox, "receiver-%d", id);
+  snprintf(mailbox,79, "receiver-%d", id);
   while (1) {
     res_irecv = MSG_task_irecv(&(task), mailbox); /* Then it posts asynchronous receives (@ref MSG_task_irecv) and*/
     XBT_INFO("Wait to receive a task");
   while (1) {
     res_irecv = MSG_task_irecv(&(task), mailbox); /* Then it posts asynchronous receives (@ref MSG_task_irecv) and*/
     XBT_INFO("Wait to receive a task");
index 6c3848e..bdef25d 100644 (file)
@@ -19,16 +19,16 @@ static int sender(int argc, char *argv[])
   msg_task_t task = NULL;
   for (i = 0; i < number_of_tasks; i++) {
     char mailbox[256];
   msg_task_t task = NULL;
   for (i = 0; i < number_of_tasks; i++) {
     char mailbox[256];
-    char sprintf_buffer[256];
-    sprintf(mailbox, "receiver-%ld", i % receivers_count);
-    sprintf(sprintf_buffer, "Task_%d", i);
-    task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL);
+    char snprintf_buffer[256];
+    snprintf(mailbox,255, "receiver-%ld", i % receivers_count);
+    snprintf(snprintf_buffer,255, "Task_%d", i);
+    task = MSG_task_create(snprintf_buffer, task_comp_size, task_comm_size, NULL);
     comm[i] = MSG_task_isend(task, mailbox);
     XBT_INFO("Send to receiver-%ld Task_%d", i % receivers_count, i);
   }
   for (i = 0; i < receivers_count; i++) {
     char mailbox[80];
     comm[i] = MSG_task_isend(task, mailbox);
     XBT_INFO("Send to receiver-%ld Task_%d", i % receivers_count, i);
   }
   for (i = 0; i < receivers_count; i++) {
     char mailbox[80];
-    sprintf(mailbox, "receiver-%ld", i % receivers_count);
+    snprintf(mailbox,79, "receiver-%ld", i % receivers_count);
     task = MSG_task_create("finalize", 0, 0, 0);
     comm[i + number_of_tasks] = MSG_task_isend(task, mailbox);
     XBT_INFO("Send to receiver-%ld finalize", i % receivers_count);
     task = MSG_task_create("finalize", 0, 0, 0);
     comm[i + number_of_tasks] = MSG_task_isend(task, mailbox);
     XBT_INFO("Send to receiver-%ld finalize", i % receivers_count);
@@ -55,7 +55,7 @@ static int receiver(int argc, char *argv[])
   read = sscanf(argv[1], "%d", &id);
   xbt_assert(read, "Invalid argument %s\n", argv[1]);
   MSG_process_sleep(10);
   read = sscanf(argv[1], "%d", &id);
   xbt_assert(read, "Invalid argument %s\n", argv[1]);
   MSG_process_sleep(10);
-  sprintf(mailbox, "receiver-%d", id);
+  snprintf(mailbox,79, "receiver-%d", id);
   while (1) {
     res_irecv = MSG_task_irecv(&(task), mailbox);
     XBT_INFO("Wait to receive a task");
   while (1) {
     res_irecv = MSG_task_irecv(&(task), mailbox);
     XBT_INFO("Wait to receive a task");
index a1340c1..f5d7631 100644 (file)
@@ -19,7 +19,7 @@ static int sender(int argc, char *argv[])
   int i;
   msg_task_t task;
   char mailbox[256];
   int i;
   msg_task_t task;
   char mailbox[256];
-  char sprintf_buffer[256];
+  char snprintf_buffer[256];
   msg_comm_t comm;
 
   for (i = 0; i < number_of_tasks; i++) {
   msg_comm_t comm;
 
   for (i = 0; i < number_of_tasks; i++) {
@@ -28,12 +28,12 @@ static int sender(int argc, char *argv[])
     else
       coef = (i + 1);
 
     else
       coef = (i + 1);
 
-    sprintf(mailbox, "receiver-%ld", (i % receivers_count));
-    sprintf(sprintf_buffer, "Task_%d", i);
-    task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size / coef, NULL);
+    snprintf(mailbox,255, "receiver-%ld", (i % receivers_count));
+    snprintf(snprintf_buffer,255, "Task_%d", i);
+    task = MSG_task_create(snprintf_buffer, task_comp_size, task_comm_size / coef, NULL);
     comm = MSG_task_isend(task, mailbox);
     xbt_dynar_push_as(d, msg_comm_t, comm);
     comm = MSG_task_isend(task, mailbox);
     xbt_dynar_push_as(d, msg_comm_t, comm);
-    XBT_INFO("Send to receiver-%ld %s comm_size %f", i % receivers_count, sprintf_buffer, task_comm_size / coef);
+    XBT_INFO("Send to receiver-%ld %s comm_size %f", i % receivers_count, snprintf_buffer, task_comm_size / coef);
   }
   /* Here we are waiting for the completion of all communications */
 
   }
   /* Here we are waiting for the completion of all communications */
 
@@ -70,7 +70,7 @@ static int receiver(int argc, char *argv[])
   XBT_ATTRIB_UNUSED int read;
   read = sscanf(argv[1], "%d", &id);
   xbt_assert(read, "Invalid argument %s\n", argv[1]);
   XBT_ATTRIB_UNUSED int read;
   read = sscanf(argv[1], "%d", &id);
   xbt_assert(read, "Invalid argument %s\n", argv[1]);
-  sprintf(mailbox, "receiver-%d", id);
+  snprintf(mailbox,79, "receiver-%d", id);
   MSG_process_sleep(10);
   msg_comm_t res_irecv;
   for (int i = 0; i < tasks; i++) {
   MSG_process_sleep(10);
   msg_comm_t res_irecv;
   for (int i = 0; i < tasks; i++) {
index 006ea0d..cb8ef29 100644 (file)
@@ -1029,27 +1029,27 @@ XBT_TEST_UNIT("string", test_dynar_string, "Dynars of strings")
   d = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
   /* 1. Populate the dynar */
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
   d = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
   /* 1. Populate the dynar */
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
-    sprintf(buf, "%d", cpt);
+    snprintf(buf,1023, "%d", cpt);
     s1 = xbt_strdup(buf);
     xbt_dynar_push(d, &s1);
   }
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
     s1 = xbt_strdup(buf);
     xbt_dynar_push(d, &s1);
   }
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
-    sprintf(buf, "%d", cpt);
+    snprintf(buf,1023, "%d", cpt);
     s1 = xbt_strdup(buf);
     xbt_dynar_replace(d, cpt, &s1);
   }
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
     s1 = xbt_strdup(buf);
     xbt_dynar_replace(d, cpt, &s1);
   }
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
-    sprintf(buf, "%d", cpt);
+    snprintf(buf,1023, "%d", cpt);
     s1 = xbt_strdup(buf);
     xbt_dynar_replace(d, cpt, &s1);
   }
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
     s1 = xbt_strdup(buf);
     xbt_dynar_replace(d, cpt, &s1);
   }
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
-    sprintf(buf, "%d", cpt);
+    snprintf(buf,1023, "%d", cpt);
     s1 = xbt_strdup(buf);
     xbt_dynar_replace(d, cpt, &s1);
   }
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
     s1 = xbt_strdup(buf);
     xbt_dynar_replace(d, cpt, &s1);
   }
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
-    sprintf(buf, "%d", cpt);
+    snprintf(buf,1023, "%d", cpt);
     xbt_dynar_shift(d, &s2);
     xbt_test_assert(!strcmp(buf, s2), "The retrieved value is not the same than the injected one (%s!=%s)", buf, s2);
     free(s2);
     xbt_dynar_shift(d, &s2);
     xbt_test_assert(!strcmp(buf, s2), "The retrieved value is not the same than the injected one (%s!=%s)", buf, s2);
     free(s2);
@@ -1061,18 +1061,18 @@ XBT_TEST_UNIT("string", test_dynar_string, "Dynars of strings")
   xbt_test_add("==== Unshift, traverse and pop %d strings", NB_ELEM);
   d = xbt_dynar_new(sizeof(char **), &xbt_free_ref);
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
   xbt_test_add("==== Unshift, traverse and pop %d strings", NB_ELEM);
   d = xbt_dynar_new(sizeof(char **), &xbt_free_ref);
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
-    sprintf(buf, "%d", cpt);
+    snprintf(buf,1023, "%d", cpt);
     s1 = xbt_strdup(buf);
     xbt_dynar_unshift(d, &s1);
   }
   /* 2. Traverse the dynar with the macro */
   xbt_dynar_foreach(d, iter, s1) {
     s1 = xbt_strdup(buf);
     xbt_dynar_unshift(d, &s1);
   }
   /* 2. Traverse the dynar with the macro */
   xbt_dynar_foreach(d, iter, s1) {
-    sprintf(buf, "%u", NB_ELEM - iter - 1);
+    snprintf(buf,1023, "%u", NB_ELEM - iter - 1);
     xbt_test_assert(!strcmp(buf, s1), "The retrieved value is not the same than the injected one (%s!=%s)", buf, s1);
   }
   /* 3. Traverse the dynar with the macro */
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
     xbt_test_assert(!strcmp(buf, s1), "The retrieved value is not the same than the injected one (%s!=%s)", buf, s1);
   }
   /* 3. Traverse the dynar with the macro */
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
-    sprintf(buf, "%d", cpt);
+    snprintf(buf,1023, "%d", cpt);
     xbt_dynar_pop(d, &s2);
     xbt_test_assert(!strcmp(buf, s2), "The retrieved value is not the same than the injected one (%s!=%s)", buf, s2);
     free(s2);
     xbt_dynar_pop(d, &s2);
     xbt_test_assert(!strcmp(buf, s2), "The retrieved value is not the same than the injected one (%s!=%s)", buf, s2);
     free(s2);
@@ -1085,32 +1085,32 @@ XBT_TEST_UNIT("string", test_dynar_string, "Dynars of strings")
   xbt_test_add("==== Push %d strings, insert %d strings in the middle, shift everything", NB_ELEM, NB_ELEM / 5);
   d = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
   xbt_test_add("==== Push %d strings, insert %d strings in the middle, shift everything", NB_ELEM, NB_ELEM / 5);
   d = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
-    sprintf(buf, "%d", cpt);
+    snprintf(buf,1023, "%d", cpt);
     s1 = xbt_strdup(buf);
     xbt_dynar_push(d, &s1);
   }
   for (cpt = 0; cpt < NB_ELEM / 5; cpt++) {
     s1 = xbt_strdup(buf);
     xbt_dynar_push(d, &s1);
   }
   for (cpt = 0; cpt < NB_ELEM / 5; cpt++) {
-    sprintf(buf, "%d", cpt);
+    snprintf(buf,1023, "%d", cpt);
     s1 = xbt_strdup(buf);
     xbt_dynar_insert_at(d, NB_ELEM / 2, &s1);
   }
 
   for (cpt = 0; cpt < NB_ELEM / 2; cpt++) {
     s1 = xbt_strdup(buf);
     xbt_dynar_insert_at(d, NB_ELEM / 2, &s1);
   }
 
   for (cpt = 0; cpt < NB_ELEM / 2; cpt++) {
-    sprintf(buf, "%d", cpt);
+    snprintf(buf,1023, "%d", cpt);
     xbt_dynar_shift(d, &s2);
     xbt_test_assert(!strcmp(buf, s2),
                      "The retrieved value is not the same than the injected one at the begining (%s!=%s)", buf, s2);
     free(s2);
   }
   for (cpt = (NB_ELEM / 5) - 1; cpt >= 0; cpt--) {
     xbt_dynar_shift(d, &s2);
     xbt_test_assert(!strcmp(buf, s2),
                      "The retrieved value is not the same than the injected one at the begining (%s!=%s)", buf, s2);
     free(s2);
   }
   for (cpt = (NB_ELEM / 5) - 1; cpt >= 0; cpt--) {
-    sprintf(buf, "%d", cpt);
+    snprintf(buf,1023, "%d", cpt);
     xbt_dynar_shift(d, &s2);
     xbt_test_assert(!strcmp(buf, s2),
                      "The retrieved value is not the same than the injected one in the middle (%s!=%s)", buf, s2);
     free(s2);
   }
   for (cpt = NB_ELEM / 2; cpt < NB_ELEM; cpt++) {
     xbt_dynar_shift(d, &s2);
     xbt_test_assert(!strcmp(buf, s2),
                      "The retrieved value is not the same than the injected one in the middle (%s!=%s)", buf, s2);
     free(s2);
   }
   for (cpt = NB_ELEM / 2; cpt < NB_ELEM; cpt++) {
-    sprintf(buf, "%d", cpt);
+    snprintf(buf,1023, "%d", cpt);
     xbt_dynar_shift(d, &s2);
     xbt_test_assert(!strcmp(buf, s2), "The retrieved value is not the same than the injected one at the end (%s!=%s)",
                      buf, s2);
     xbt_dynar_shift(d, &s2);
     xbt_test_assert(!strcmp(buf, s2), "The retrieved value is not the same than the injected one at the end (%s!=%s)",
                      buf, s2);
@@ -1123,12 +1123,12 @@ XBT_TEST_UNIT("string", test_dynar_string, "Dynars of strings")
   xbt_test_add("==== Push %d strings, remove %d-%d. free the rest", NB_ELEM, 2 * (NB_ELEM / 5), 4 * (NB_ELEM / 5));
   d = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
   xbt_test_add("==== Push %d strings, remove %d-%d. free the rest", NB_ELEM, 2 * (NB_ELEM / 5), 4 * (NB_ELEM / 5));
   d = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
-    sprintf(buf, "%d", cpt);
+    snprintf(buf,1023, "%d", cpt);
     s1 = xbt_strdup(buf);
     xbt_dynar_push(d, &s1);
   }
   for (cpt = 2 * (NB_ELEM / 5); cpt < 4 * (NB_ELEM / 5); cpt++) {
     s1 = xbt_strdup(buf);
     xbt_dynar_push(d, &s1);
   }
   for (cpt = 2 * (NB_ELEM / 5); cpt < 4 * (NB_ELEM / 5); cpt++) {
-    sprintf(buf, "%d", cpt);
+    snprintf(buf,1023, "%d", cpt);
     xbt_dynar_remove_at(d, 2 * (NB_ELEM / 5), &s2);
     xbt_test_assert(!strcmp(buf, s2), "Remove a bad value. Got %s, expected %s", s2, buf);
     free(s2);
     xbt_dynar_remove_at(d, 2 * (NB_ELEM / 5), &s2);
     xbt_test_assert(!strcmp(buf, s2), "Remove a bad value. Got %s, expected %s", s2, buf);
     free(s2);