x = CORD_cat(x,x);
if (CORD_sprintf(&result, "->%-120.78r!\n", x) != 124)
ABORT("CORD_sprintf failed 3");
- (void) sprintf(result2, "->%-120.78s!\n", CORD_to_char_star(x));
+ (void)snprintf(result2, sizeof(result2), "->%-120.78s!\n",
+ CORD_to_char_star(x));
+ result2[sizeof(result2) - 1] = '\0';
if (CORD_cmp(result, result2) != 0)ABORT("CORD_sprintf goofed 5");
}
# endif /* SOLARISDL */
if (fd < 0) {
- sprintf(buf, "/proc/%ld", (long)getpid());
+ (void)snprintf(buf, sizeof(buf), "/proc/%ld", (long)getpid());
+ buf[sizeof(buf) - 1] = '\0';
/* The above generates a lint complaint, since pid_t varies. */
/* It's unclear how to improve this. */
fd = open(buf, O_RDONLY);
fmt = GC_dyld_add_sect_fmts[j];
/* Add our manufactured aligned BSS sections. */
for (i = 0; i <= L2_MAX_OFILE_ALIGNMENT; i++) {
- snprintf(secnam, sizeof(secnam), fmt, (unsigned)i);
+ (void)snprintf(secnam, sizeof(secnam), fmt, (unsigned)i);
+ secnam[sizeof(secnam) - 1] = '\0';
sec = GC_GETSECTBYNAME(hdr, SEG_DATA, secnam);
if (sec == NULL || sec->size == 0)
continue;
for (j = 0; j < sizeof(GC_dyld_add_sect_fmts) / sizeof(char *); j++) {
fmt = GC_dyld_add_sect_fmts[j];
for (i = 0; i <= L2_MAX_OFILE_ALIGNMENT; i++) {
- snprintf(secnam, sizeof(secnam), fmt, (unsigned)i);
+ (void)snprintf(secnam, sizeof(secnam), fmt, (unsigned)i);
+ secnam[sizeof(secnam) - 1] = '\0';
sec = GC_GETSECTBYNAME(hdr, SEG_DATA, secnam);
if (sec == NULL || sec->size == 0)
continue;
+ GC_bytes_allocd_before_gc));
}
- sprintf(buf, "/proc/%ld", (long)getpid());
+ (void)snprintf(buf, sizeof(buf), "/proc/%ld", (long)getpid());
+ buf[sizeof(buf) - 1] = '\0';
fd = open(buf, O_RDONLY);
if (fd < 0) {
ABORT("/proc open failed");
# else
char buf[40];
char *name = buf;
- sprintf(buf, "##PC##= 0x%lx", info[i].ci_pc);
+ (void)snprintf(buf, sizeof(buf), "##PC##= 0x%lx", info[i].ci_pc);
+ buf[sizeof(buf) - 1] = '\0';
# endif
# if defined(LINUX) && !defined(SMALL_CONFIG)
/* Try for a line number. */
/* Then we use popen to start addr2line -e <exe> <addr> */
/* There are faster ways to do this, but hopefully this */
/* isn't time critical. */
- sprintf(cmd_buf, "/usr/bin/addr2line -f -e %s 0x%lx", exe_name,
- (unsigned long)info[i].ci_pc);
+ (void)snprintf(cmd_buf, sizeof(cmd_buf),
+ "/usr/bin/addr2line -f -e %s 0x%lx",
+ exe_name, (unsigned long)info[i].ci_pc);
+ cmd_buf[sizeof(cmd_buf) - 1] = '\0';
old_preload = GETENV("LD_PRELOAD");
if (0 != old_preload) {
size_t old_len = strlen(old_preload);
}
if (result_len < RESULT_SZ - 25) {
/* Add in hex address */
- sprintf(result_buf + result_len, " [0x%lx]",
- (unsigned long)info[i].ci_pc);
+ (void)snprintf(&result_buf[result_len],
+ sizeof(result_buf) - result_len,
+ " [0x%lx]", (unsigned long)info[i].ci_pc);
+ result_buf[sizeof(result_buf) - 1] = '\0';
}
name = result_buf;
pclose(pipe);