From a5945452ef5b1114fd7c2fab0e865d776775c34d Mon Sep 17 00:00:00 2001 From: degomme Date: Wed, 1 Jun 2016 01:25:32 +0200 Subject: [PATCH] Replace sprintf by snprintf. --- examples/msg/maestro-set/maestro-set.c | 4 +-- examples/msg/network-ns3/network-ns3.c | 7 ++-- examples/smpi/NAS/dt.c | 20 +++++------ examples/smpi/NAS/ep.c | 2 +- .../masterslave_mailbox_smpi.c | 16 ++++----- src/bindings/lua/lua_debug.cpp | 18 +++++----- src/instr/jedule/jedule_output.cpp | 6 ++-- src/simdag/dax_dtd.c | 4 +-- src/simdag/sd_dotloader.cpp | 5 +-- src/simgrid/sg_config.cpp | 6 ++-- src/smpi/colls/smpi_automatic_selector.c | 2 +- src/surf/maxmin.cpp | 36 +++++++++---------- src/surf/ns3/ns3_simulator.h | 2 +- src/surf/xml/simgrid_dtd.c | 4 +-- src/xbt/backtrace_linux.c | 9 ++--- src/xbt/cunit.c | 2 +- src/xbt/dict.c | 6 ++-- src/xbt/mmalloc/mmorecore.c | 2 +- src/xbt/xbt_str.c | 8 ++--- teshsuite/msg/concurrent_rw/concurrent_rw.c | 2 +- 20 files changed, 81 insertions(+), 80 deletions(-) diff --git a/examples/msg/maestro-set/maestro-set.c b/examples/msg/maestro-set/maestro-set.c index 859f14536c..f22c97fb2a 100644 --- a/examples/msg/maestro-set/maestro-set.c +++ b/examples/msg/maestro-set/maestro-set.c @@ -38,7 +38,7 @@ static int sender(int argc, char *argv[]) /* Latency */ time = MSG_get_clock(); - sprintf(sprintf_buffer_la, "latency task"); + snprintf(sprintf_buffer_la,64, "latency task"); task_la = MSG_task_create(sprintf_buffer_la, 0.0, task_comm_size_lat, NULL); task_la->data = xbt_new(double, 1); *(double *) task_la->data = time; @@ -47,7 +47,7 @@ static int sender(int argc, char *argv[]) /* Bandwidth */ time = MSG_get_clock(); - sprintf(sprintf_buffer_bw, "bandwidth task"); + snprintf(sprintf_buffer_bw,64, "bandwidth task"); task_bw = MSG_task_create(sprintf_buffer_bw, 0.0, task_comm_size_bw, NULL); task_bw->data = xbt_new(double, 1); *(double *) task_bw->data = time; diff --git a/examples/msg/network-ns3/network-ns3.c b/examples/msg/network-ns3/network-ns3.c index 19b95c880b..c422f5c502 100644 --- a/examples/msg/network-ns3/network-ns3.c +++ b/examples/msg/network-ns3/network-ns3.c @@ -36,7 +36,8 @@ static int master(int argc, char *argv[]) /* worker name */ char *workername = argv[2]; int id = xbt_str_parse_int(argv[3], "Invalid ID as argument 3: %s"); //unique id to control statistics - char *id_alias = bprintf("flow_%d", id); + char *id_alias = xbt_malloc(20*sizeof(char)); + snprintf(id_alias, 20, "flow_%d", id); workernames[id] = workername; TRACE_category(id_alias); @@ -56,7 +57,7 @@ static int master(int argc, char *argv[]) timer_start = 1 ; /* time measurement */ - sprintf(id_alias, "%d", id); + snprintf(id_alias,20,"%d", id); start_time = MSG_get_clock(); MSG_task_send(todo, id_alias); end_time = MSG_get_clock(); @@ -101,7 +102,7 @@ static int worker(int argc, char *argv[]) XBT_DEBUG ("Worker started"); int id = xbt_str_parse_int(argv[1], "Invalid id: %s"); - sprintf(id_alias, "%d", id); + snprintf(id_alias,10, "%d", id); msg_error_t a = MSG_task_receive(&(task), id_alias); diff --git a/examples/smpi/NAS/dt.c b/examples/smpi/NAS/dt.c index e38b99ee03..1c87e5a0b0 100644 --- a/examples/smpi/NAS/dt.c +++ b/examples/smpi/NAS/dt.c @@ -170,7 +170,7 @@ static DGraph *buildSH(const char cls){ unsigned int i=0,j=0; char nm[BLOCK_SIZE]; - snprintf(nm,BLOCK_SIZE -1,"DT_SH.%c",cls); + snprintf(nm,BLOCK_SIZE,"DT_SH.%c",cls); dg=newDGraph(nm); while(tmpS>1){ @@ -178,14 +178,14 @@ static DGraph *buildSH(const char cls){ tmpS>>=1; } for(i=0;iname, number_of_tasks, mailbox); @@ -37,7 +37,7 @@ static int master(int argc, char *argv[]) for (i = 0; i < slaves_count; i++) { char mailbox[80]; - sprintf(mailbox, "slave-%ld", i % slaves_count); + snprintf(mailbox,80, "slave-%ld", i % slaves_count); msg_task_t finalize = MSG_task_create("finalize", 0, 0, 0); MSG_task_send(finalize, mailbox); } @@ -69,7 +69,8 @@ static int alltoall_mpi(int argc, char *argv[]) { MPI_Init(&argc, &argv); - int rank, size; + int rank; + int size; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); XBT_INFO("alltoall for rank %d", rank); @@ -95,20 +96,17 @@ static int slave(int argc, char *argv[]) read = sscanf(argv[1], "%d", &id); xbt_assert(read, "Invalid argument %s\n", argv[1]); - sprintf(mailbox, "slave-%d", id); + snprintf(mailbox,80, "slave-%d", id); while (1) { res = MSG_task_receive(&(task), mailbox); xbt_assert(res == MSG_OK, "MSG_task_get failed"); -// XBT_INFO("Received \"%s\"", MSG_task_get_name(task)); - if (!strcmp(MSG_task_get_name(task), "finalize")) { + if (strcmp(MSG_task_get_name(task), "finalize")==0) { MSG_task_destroy(task); break; } -// XBT_INFO("Processing \"%s\"", MSG_task_get_name(task)); MSG_task_execute(task); -// XBT_INFO("\"%s\" done", MSG_task_get_name(task)); MSG_task_destroy(task); task = NULL; } diff --git a/src/bindings/lua/lua_debug.cpp b/src/bindings/lua/lua_debug.cpp index d0c0db6411..171b847506 100644 --- a/src/bindings/lua/lua_debug.cpp +++ b/src/bindings/lua/lua_debug.cpp @@ -37,15 +37,15 @@ const char* sglua_tostring(lua_State* L, int index) { switch (lua_type(L, index)) { case LUA_TNIL: - sprintf(buff, "nil"); + snprintf(buff, 4, "nil"); break; case LUA_TNUMBER: - sprintf(buff, "%.3f", lua_tonumber(L, index)); + snprintf(buff, 64, "%.3f", lua_tonumber(L, index)); break; case LUA_TBOOLEAN: - sprintf(buff, "%s", lua_toboolean(L, index) ? "true" : "false"); + snprintf(buff, 64, "%s", lua_toboolean(L, index) ? "true" : "false"); break; case LUA_TSTRING: @@ -54,24 +54,24 @@ const char* sglua_tostring(lua_State* L, int index) { case LUA_TFUNCTION: if (lua_iscfunction(L, index)) { - sprintf(buff, "C-function"); + snprintf(buff, 11, "C-function"); } else { - sprintf(buff, "function"); + snprintf(buff, 9, "function"); } break; case LUA_TTABLE: - sprintf(buff, "table(%p)", lua_topointer(L, index)); + snprintf(buff, 64, "table(%p)", lua_topointer(L, index)); break; case LUA_TLIGHTUSERDATA: case LUA_TUSERDATA: - sprintf(buff, "userdata(%p)", lua_touserdata(L, index)); + snprintf(buff, 64, "userdata(%p)", lua_touserdata(L, index)); break; case LUA_TTHREAD: - sprintf(buff, "thread"); + snprintf(buff, 7, "thread"); break; } return buff; @@ -164,7 +164,7 @@ void sglua_stack_dump(lua_State* L, const char* msg) p[0] = '\0'; for (int i = 1; i <= top; i++) { /* repeat for each level */ - p += sprintf(p, "%s ", sglua_tostring(L, i)); + p += snprintf(p, 2048-(p-buff), "%s ", sglua_tostring(L, i)); } XBT_DEBUG("%s%s", msg, buff); diff --git a/src/instr/jedule/jedule_output.cpp b/src/instr/jedule/jedule_output.cpp index a0c34619e4..f2d64daac3 100644 --- a/src/instr/jedule/jedule_output.cpp +++ b/src/instr/jedule/jedule_output.cpp @@ -67,11 +67,11 @@ static void get_hierarchy_string(jed_simgrid_container_t container, char *outbuf xbt_dynar_foreach(hier_list, iter, number) { if( iter != length-1 ) { - sprintf(buf, "%d.", number); + snprintf(buf, 1024, "%d.", number); } else { - sprintf(buf, "%d", number); + snprintf(buf, 1024, "%d", number); } - strcat(outbuf, buf); + sntrcat(outbuf, buf, strlen(buf)); } xbt_dynar_free(&hier_list); diff --git a/src/simdag/dax_dtd.c b/src/simdag/dax_dtd.c index be760b589f..4e788339fc 100644 --- a/src/simdag/dax_dtd.c +++ b/src/simdag/dax_dtd.c @@ -3891,11 +3891,11 @@ static int fail(const char* fmt, ...) int chars_left, used; va_list ap; va_start(ap, fmt); #ifdef FLEXML_yylineno - used = sprintf(flexml_err_msg, + used = snprintf(flexml_err_msg,flexml_max_err_msg_size, "Invalid XML (XML input line %d, state %d): ", dax_lineno, YY_START); #else - used = sprintf(flexml_err_msg, + used = snprintf(flexml_err_msg,flexml_max_err_msg_size, "Invalid XML (state %d): ", YY_START); #endif diff --git a/src/simdag/sd_dotloader.cpp b/src/simdag/sd_dotloader.cpp index 423df637c8..759b2b5970 100644 --- a/src/simdag/sd_dotloader.cpp +++ b/src/simdag/sd_dotloader.cpp @@ -167,8 +167,9 @@ xbt_dynar_t SD_dotload_generic(const char * filename, seq_par_t seq_or_par, bool dst = (SD_task_t)xbt_dict_get_or_null(jobs, dst_name); if (size > 0) { - char *name = (char*)xbt_malloc((strlen(src_name)+strlen(dst_name)+6)*sizeof(char)); - sprintf(name, "%s->%s", src_name, dst_name); + int namesize=(strlen(src_name)+strlen(dst_name)+6); + char *name = (char*)xbt_malloc(namesize*sizeof(char*)); + snprintf(name,namesize, "%s->%s", src_name, dst_name); XBT_DEBUG("See ", name, size); if (!(task = (SD_task_t)xbt_dict_get_or_null(jobs, name))) { if (seq_or_par == sequential) diff --git a/src/simgrid/sg_config.cpp b/src/simgrid/sg_config.cpp index d7b07e86b7..7578e0506f 100644 --- a/src/simgrid/sg_config.cpp +++ b/src/simgrid/sg_config.cpp @@ -369,11 +369,11 @@ static void describe_model(char *result, const char *description) { char *p = result + - sprintf(result, "%s. Possible values: %s", description, + snprintf(result,1024-strlen(result), "%s. Possible values: %s", description, model_description[0].name ? model_description[0].name : "n/a"); for (int i = 1; model_description[i].name; i++) - p += sprintf(p, ", %s", model_description[i].name); - sprintf(p, ".\n (use 'help' as a value to see the long description of each %s)", name); + p += snprintf(p,1024, ", %s", model_description[i].name); + snprintf(p,1024, ".\n (use 'help' as a value to see the long description of each %s)", name); } /* create the config set, register what should be and parse the command line*/ diff --git a/src/smpi/colls/smpi_automatic_selector.c b/src/smpi/colls/smpi_automatic_selector.c index 0108d4cd7c..29455c2b80 100644 --- a/src/smpi/colls/smpi_automatic_selector.c +++ b/src/smpi/colls/smpi_automatic_selector.c @@ -15,7 +15,7 @@ type=PJ_type_event_new(#cat, PJ_type_get_root());\ }\ char cont_name[25];\ - sprintf(cont_name, "rank-%d", smpi_process_index());\ + snprintf(cont_name,25, "rank-%d", smpi_process_index());\ val_t value = PJ_value_get_or_new(mpi_coll_##cat##_description[i].name,"1.0 1.0 1.0", type);\ new_pajeNewEvent (SIMIX_get_clock(), PJ_container_get(cont_name), type, value);\ } diff --git a/src/surf/maxmin.cpp b/src/surf/maxmin.cpp index 0ea8e653b5..abfb09b3db 100644 --- a/src/surf/maxmin.cpp +++ b/src/surf/maxmin.cpp @@ -634,18 +634,18 @@ void lmm_print(lmm_system_t sys) /* Printing Objective */ var_list = &(sys->variable_set); - sprintf(print_buf, "MAX-MIN ( "); + snprintf(print_buf,11, "MAX-MIN ( "); trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); - strcat(trace_buf, print_buf); + strncat(trace_buf, print_buf, strlen(print_buf)); xbt_swag_foreach(_var, var_list) { var = (lmm_variable_t)_var; - sprintf(print_buf, "'%d'(%f) ", var->id_int, var->weight); + snprintf(print_buf,1024, "'%d'(%f) ", var->id_int, var->weight); trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); - strcat(trace_buf, print_buf); + strncat(trace_buf, print_buf, strlen(print_buf)); } - sprintf(print_buf, ")"); + snprintf(print_buf,2, ")"); trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); - strcat(trace_buf, print_buf); + strncat(trace_buf, print_buf, strlen(print_buf)); XBT_DEBUG("%20s", trace_buf); trace_buf[0] = '\000'; @@ -657,18 +657,18 @@ void lmm_print(lmm_system_t sys) sum = 0.0; //Show the enabled variables elem_list = &(cnst->enabled_element_set); - sprintf(print_buf, "\t"); + snprintf(print_buf,2, "\t"); trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); - strcat(trace_buf, print_buf); - sprintf(print_buf, "%s(",(cnst->sharing_policy)?"":"max"); + strncat(trace_buf, print_buf, strlen(print_buf)); + snprintf(print_buf,1024, "%s(",(cnst->sharing_policy)?"":"max"); trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); - strcat(trace_buf, print_buf); + strncat(trace_buf, print_buf, strlen(print_buf)); xbt_swag_foreach(_elem, elem_list) { elem = (lmm_element_t)_elem; - sprintf(print_buf, "%f.'%d'(%f) %s ", elem->value, + snprintf(print_buf,1024, "%f.'%d'(%f) %s ", elem->value, elem->variable->id_int, elem->variable->value,(cnst->sharing_policy)?"+":","); trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); - strcat(trace_buf, print_buf); + strncat(trace_buf, print_buf, strlen(print_buf)); if(cnst->sharing_policy) sum += elem->value * elem->variable->value; else @@ -678,24 +678,24 @@ void lmm_print(lmm_system_t sys) elem_list = &(cnst->disabled_element_set); xbt_swag_foreach(_elem, elem_list) { elem = (lmm_element_t)_elem; - sprintf(print_buf, "%f.'%d'(%f) %s ", elem->value, + snprintf(print_buf,1024, "%f.'%d'(%f) %s ", elem->value, elem->variable->id_int, elem->variable->value,(cnst->sharing_policy)?"+":","); trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); - strcat(trace_buf, print_buf); + strncat(trace_buf, print_buf, strlen(print_buf)); if(cnst->sharing_policy) sum += elem->value * elem->variable->value; else sum = MAX(sum,elem->value * elem->variable->value); } - sprintf(print_buf, "0) <= %f ('%d')", cnst->bound, cnst->id_int); + snprintf(print_buf,1024, "0) <= %f ('%d')", cnst->bound, cnst->id_int); trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); - strcat(trace_buf, print_buf); + strncat(trace_buf, print_buf, strlen(print_buf)); if (!cnst->sharing_policy) { - sprintf(print_buf, " [MAX-Constraint]"); + snprintf(print_buf,1024, " [MAX-Constraint]"); trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); - strcat(trace_buf, print_buf); + strncat(trace_buf, print_buf, strlen(print_buf)); } XBT_DEBUG("%s", trace_buf); trace_buf[0] = '\000'; diff --git a/src/surf/ns3/ns3_simulator.h b/src/surf/ns3/ns3_simulator.h index 8cec673f99..1114a721d0 100644 --- a/src/surf/ns3/ns3_simulator.h +++ b/src/surf/ns3/ns3_simulator.h @@ -44,7 +44,7 @@ static inline const char *transformSocketPtr (ns3::Ptr localSocket) static char key[24]; std::stringstream sstream; sstream << localSocket ; - sprintf(key,"%s",sstream.str().c_str()); + snprintf(key,24,"%s",sstream.str().c_str()); return key; } diff --git a/src/surf/xml/simgrid_dtd.c b/src/surf/xml/simgrid_dtd.c index f3167441c1..2af7590fd1 100644 --- a/src/surf/xml/simgrid_dtd.c +++ b/src/surf/xml/simgrid_dtd.c @@ -10305,11 +10305,11 @@ static int fail(const char* fmt, ...) int chars_left, used; va_list ap; va_start(ap, fmt); #ifdef FLEXML_yylineno - used = sprintf(flexml_err_msg, + used = snprintf(flexml_err_msg,flexml_max_err_msg_size, "Invalid XML (XML input line %d, state %d): ", surf_parse_lineno, YY_START); #else - used = sprintf(flexml_err_msg, + used = snprintf(flexml_err_msg,flexml_max_err_msg_size, "Invalid XML (state %d): ", YY_START); #endif diff --git a/src/xbt/backtrace_linux.c b/src/xbt/backtrace_linux.c index e1de958cda..a1e3fcbf2a 100644 --- a/src/xbt/backtrace_linux.c +++ b/src/xbt/backtrace_linux.c @@ -170,9 +170,10 @@ void xbt_ex_setup_backtrace(xbt_ex_t * e) //FIXME: This code could be greatly im } else { binary_name = xbt_strdup(xbt_binary_name); } - cmd = curr = xbt_new(char, strlen(ADDR2LINE) + 25 + strlen(binary_name) + 32 * e->used); + int strsize=strlen(ADDR2LINE) + 25 + strlen(binary_name) + 32 * e->used; + cmd = curr = xbt_new(char, strsize); - curr += sprintf(curr, "%s -f -e %s ", ADDR2LINE, binary_name); + curr += snprintf(curr,strsize, "%s -f -e %s ", ADDR2LINE, binary_name); free(binary_name); addrs = xbt_new(char *, e->used); @@ -190,7 +191,7 @@ void xbt_ex_setup_backtrace(xbt_ex_t * e) //FIXME: This code could be greatly im XBT_DEBUG("Set up a new address: %d, '%s'(%p)", i, addrs[i], addrs[i]); /* Add it to the command line args */ - curr += sprintf(curr, "%s ", addrs[i]); + curr += snprintf(curr,strsize, "%s ", addrs[i]); } addr_len = strlen(addrs[0]); @@ -289,7 +290,7 @@ void xbt_ex_setup_backtrace(xbt_ex_t * e) //FIXME: This code could be greatly im if (p[0] == '[') { /* library path not displayed in the map file either... */ free(p); - sprintf(line_func, "??"); + snprintf(line_func,3, "??"); } else { p2 = strrchr(p, '('); if (p2) diff --git a/src/xbt/cunit.c b/src/xbt/cunit.c index d4915f17cf..b669bfa632 100644 --- a/src/xbt/cunit.c +++ b/src/xbt/cunit.c @@ -266,7 +266,7 @@ static int xbt_test_suite_run(xbt_test_suite_t suite, int verbosity) suite_title[i++] = '\n'; suite_title[80] = '\0'; - sprintf(suite_title + 40 - (suite_len + 4) / 2, "[ %s ]", suite->title); + snprintf(suite_title + 40 - (suite_len + 4) / 2, 81-(40 - (suite_len + 4)/ 2), "[ %s ]", suite->title); suite_title[40 + (suite_len + 5) / 2] = '='; if (!suite->enabled) snprintf(suite_title + 70, 11, " DISABLED "); diff --git a/src/xbt/dict.c b/src/xbt/dict.c index 6e2135d20c..8c98500127 100644 --- a/src/xbt/dict.c +++ b/src/xbt/dict.c @@ -982,7 +982,7 @@ XBT_TEST_UNIT("crash", test_dict_crash, "Crash test") /* if (!(j%1000)) { printf("."); fflush(stdout); } */ key = xbt_malloc(10); - sprintf(key, "%d", j); + snprintf(key,10, "%d", j); xbt_dict_set(head, key, key, &free); } /*xbt_dict_dump(head,(void (*)(void*))&printf); */ @@ -997,7 +997,7 @@ XBT_TEST_UNIT("crash", test_dict_crash, "Crash test") void *data; /* if (i%10) printf("."); else printf("%d",i/10); fflush(stdout); */ for (j = 0; j < NB_ELM; j++) { - sprintf(key, "%d", j); + snprintf(key,10, "%d", j); data = xbt_dict_get(head, key); xbt_test_assert(!strcmp(key, (char *) data), "with get, key=%s != data=%s", key, (char *) data); data = xbt_dict_get_ext(head, key, strlen(key)); @@ -1010,7 +1010,7 @@ XBT_TEST_UNIT("crash", test_dict_crash, "Crash test") key = xbt_malloc(10); for (j = 0; j < NB_ELM; j++) { /* if (!(j%10000)) printf("."); fflush(stdout); */ - sprintf(key, "%d", j); + snprintf(key,10, "%d", j); xbt_dict_remove(head, key); } free(key); diff --git a/src/xbt/mmalloc/mmorecore.c b/src/xbt/mmalloc/mmorecore.c index c80e74fb50..5227d08d20 100644 --- a/src/xbt/mmalloc/mmorecore.c +++ b/src/xbt/mmalloc/mmorecore.c @@ -124,7 +124,7 @@ void *mmorecore(struct mdesc *mdp, ssize_t size) if (mapto == MAP_FAILED) { char buff[1024]; fprintf(stderr,"Internal error: mmap returned MAP_FAILED! error: %s\n",strerror(errno)); - sprintf(buff,"cat /proc/%d/maps",getpid()); + snprintf(buff,1024,"cat /proc/%d/maps",getpid()); int status = system(buff); if (status == -1 || !(WIFEXITED(status) && WEXITSTATUS(status) == 0)) fprintf(stderr, "Something went wrong when trying to %s\n", buff); diff --git a/src/xbt/xbt_str.c b/src/xbt/xbt_str.c index 6a54bb9177..551aa9916c 100644 --- a/src/xbt/xbt_str.c +++ b/src/xbt/xbt_str.c @@ -416,9 +416,9 @@ char *xbt_str_join(xbt_dynar_t dyn, const char *sep) p = res; xbt_dynar_foreach(dyn, cpt, cursor) { if ((int) cpt < dyn_len - 1) - p += sprintf(p, "%s%s", cursor, sep); + p += snprintf(p,len, "%s%s", cursor, sep); else - p += sprintf(p, "%s", cursor); + p += snprintf(p,len, "%s", cursor); } return res; } @@ -449,9 +449,9 @@ char *xbt_str_join_array(const char *const *strs, const char *sep) q = res = xbt_malloc(len); for (i=0;strs[i];i++) { if (i!=0) { // not first loop - q += sprintf(q, "%s%s", sep, strs[i]); + q += snprintf(q,len, "%s%s", sep, strs[i]); } else { - q += sprintf(q,"%s",strs[i]); + q += snprintf(q,len, "%s",strs[i]); } } return res; diff --git a/teshsuite/msg/concurrent_rw/concurrent_rw.c b/teshsuite/msg/concurrent_rw/concurrent_rw.c index 2024745368..9231629261 100644 --- a/teshsuite/msg/concurrent_rw/concurrent_rw.c +++ b/teshsuite/msg/concurrent_rw/concurrent_rw.c @@ -15,7 +15,7 @@ static int host(int argc, char *argv[]) { char name[2048]; int id = MSG_process_self_PID(); - sprintf(name,"%s%i", FILENAME1, id); + snprintf(name,2048,"%s%i", FILENAME1, id); msg_file_t file = MSG_file_open(name, NULL); XBT_INFO("process %d is writing!", id); MSG_file_write(file, 3000000); -- 2.20.1