} 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);
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]);
line_func[strlen(line_func) - 1] = '\0';
} else {
XBT_VERB("Cannot run fgets to look for symbol %d, addr %s", i, addrs[i]);
- strcpy(line_func, "???");
+ strncpy(line_func, "???",3);
}
if (fgets(line_pos, 1024, pipe)) {
line_pos[strlen(line_pos) - 1] = '\0';
} else {
XBT_VERB("Cannot run fgets to look for symbol %d, addr %s", i, addrs[i]);
- strcpy(line_pos, backtrace_syms[i]);
+ strncpy(line_pos, backtrace_syms[i],1024);
}
if (strcmp("??", line_func) != 0) {
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)
line_func[strlen(line_func) - 1] = '\0';
} else {
XBT_VERB("Cannot read result of subcommand %s", subcmd);
- strcpy(line_func, "???");
+ strncpy(line_func, "???",3);
}
if (fgets(line_pos, 1024, subpipe)) {
line_pos[strlen(line_pos) - 1] = '\0';
} else {
XBT_VERB("Cannot read result of subcommand %s", subcmd);
- strcpy(line_pos, backtrace_syms[i]);
+ strncpy(line_pos, backtrace_syms[i],1024);
}
pclose(subpipe);
free(subcmd);