1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

removed direct calls to strncat (DANGEROUS)

This commit is contained in:
Steffen Vogel 2015-03-31 13:50:30 +02:00
parent 64e0785504
commit 860bd6b654
2 changed files with 10 additions and 14 deletions

View file

@ -139,17 +139,14 @@ void hist_plot(struct hist *h)
void hist_dump(struct hist *h, char *buf, int len)
{
char tok[8];
memset(buf, 0, len);
*buf = 0;
strncat(buf, "[ ", len);
strap(buf, len, "[ ");
for (int i = 0; i < h->length; i++) {
snprintf(tok, sizeof(tok), "%u ", h->data[i]);
strncat(buf, tok, len - strlen(buf));
}
strncat(buf, "]", len - strlen(buf));
for (int i = 0; i < h->length; i++)
strap(buf, len, "%u ", h->data[i]);
strap(buf, len, "]");
}
void hist_matlab(struct hist *h, FILE *f)

View file

@ -101,16 +101,15 @@ struct timespec timespec_rate(double rate)
/** @todo: Proper way: create additional pipe for stderr in child process */
int system2(const char *cmd, ...)
{
va_list ap;
char buf[1024];
va_list ap;
va_start(ap, cmd);
vsnprintf(buf, sizeof(buf), cmd, ap);
strncat(buf, " 2>&1", sizeof(buf));
vsnprintf(buf, sizeof(buf), cmd, ap);
va_end(ap);
strap(buf, sizeof(buf), " 2>&1", sizeof(buf)); /* redirect stderr to stdout */
debug(1, "System: %s", buf);
FILE *f = popen(buf, "r");