case VG_USERREQ__DUMP_STATS_AT:
{
- HChar buf[512];
- VG_(sprintf)(buf,"Client Request: %s", (HChar*)args[1]);
+ const HChar *arg = (HChar*)args[1];
+ HChar buf[30 + VG_(strlen)(arg)]; // large enough
+ VG_(sprintf)(buf,"Client Request: %s", arg);
CLG_(dump_profile)(buf, True);
*ret = 0; /* meaningless */
}
{
/* check for dumps needed */
static ULong bbs_done = 0;
- static HChar buf[512];
+ HChar buf[50]; // large enough
if (CLG_(clo).dump_every_bb >0) {
if (CLG_(stat).bb_executions - bbs_done > CLG_(clo).dump_every_bb) {
# if 0
{
- HChar buf[100];
+ HChar buf[100]; // large enough
VG_(am_show_nsegments)(0,"post syncheck failure");
VG_(sprintf)(buf, "/bin/cat /proc/%d/maps", VG_(getpid)());
VG_(system)(buf);
unsigned long gdb_id;
struct thread_info *ti;
ThreadState *tst;
- char status[100];
gdb_id = strtoul (&arg_own_buf[17], NULL, 16);
ti = gdb_id_to_thread (gdb_id);
tst = (ThreadState *) inferior_target_data (ti);
/* Additional info is the tid, the thread status and the thread's
name, if any. */
+ SizeT len = strlen(VG_(name_of_ThreadStatus)(tst->status)) + 20;
+ if (tst->thread_name) len += strlen(tst->thread_name);
+ /* As the string will be hexified and copied into own_buf we need
+ to limit the length to avoid buffer overflow. */
+ if (len * 2 > (PBUFSIZ + POVERHSIZ))
+ len = (PBUFSIZ + POVERHSIZ) / 2;
+ char status[len];
if (tst->thread_name) {
VG_(snprintf) (status, sizeof(status), "tid %d %s %s",
tst->tid,
static
char *image_ptid(unsigned long ptid)
{
- static char result[100];
+ static char result[50]; // large enough
VG_(sprintf) (result, "id %ld", ptid);
return result;
}
#if 0
if (VG_(clo_trace_sched)) {
- HChar buf[100];
- vg_assert(VG_(strlen)(who) <= 100-50);
+ HChar buf[VG_(strlen)(who) + 30];
VG_(sprintf)(buf, "waiting for lock (%s)", who);
print_sched_event(tid, buf);
}
}
if (VG_(clo_trace_sched)) {
- HChar buf[150];
- vg_assert(VG_(strlen)(who) <= 150-50);
+ HChar buf[VG_(strlen)(who) + 30];
VG_(sprintf)(buf, " acquired lock (%s)", who);
print_sched_event(tid, buf);
}
VG_(running_tid) = VG_INVALID_THREADID;
if (VG_(clo_trace_sched)) {
- HChar buf[200];
- vg_assert(VG_(strlen)(who) <= 200-100);
- VG_(sprintf)(buf, "releasing lock (%s) -> %s",
- who, VG_(name_of_ThreadStatus)(sleepstate));
+ const HChar *status = VG_(name_of_ThreadStatus)(sleepstate);
+ HChar buf[VG_(strlen)(who) + VG_(strlen)(status) + 30];
+ VG_(sprintf)(buf, "releasing lock (%s) -> %s", who, status);
print_sched_event(tid, buf);
}
struct vki_sigcontext sigcontext;
struct vki_mcontext mcontext;
struct vg_sig_private priv;
- unsigned char abigap[224];
+ unsigned char abigap[224]; // unused
};
/* Structure put on stack for signal handlers with SA_SIGINFO set. */
vki_siginfo_t siginfo;
struct vki_ucontext ucontext;
struct vg_sig_private priv;
- unsigned char abigap[224];
+ unsigned char abigap[224]; // unused
};
#define SET_SIGNAL_LR(zztst, zzval) \
void* puc;
vki_siginfo_t info;
struct vg_sig_private priv;
- UChar abigap[288];
+ UChar abigap[288]; // unused
};
#define SET_SIGNAL_LR(zztst, zzval) \
static
HChar* format_sigset ( const vki_sigset_t* set )
{
- static HChar buf[128];
+ static HChar buf[_VKI_NSIG_WORDS * 16 + 1];
int w;
VG_(strcpy)(buf, "");
}
#if 0
{
- HChar buf[110];
+ HChar buf[50]; // large enough
VG_(am_show_nsegments)(0,"post segfault");
VG_(sprintf)(buf, "/bin/cat /proc/%d/maps", VG_(getpid)());
VG_(system)(buf);
static
char *status_image (int status)
{
- static char result[256];
+ static char result[256]; // large enough
int sz = 0;
#define APPEND(...) sz += snprintf (result+sz, 256 - sz - 1, __VA_ARGS__)
static Bool is_sane_Descr_and_Tree ( UShort descr, SVal* tree ) {
Word i;
UChar validbits = descr_to_validbits(descr);
- HChar buf[128], buf2[128];
+ HChar buf[128], buf2[128]; // large enough
if (validbits == 0)
goto bad;
for (i = 0; i < 8; i++) {