Fixed bug in potential reuse of args in vsnprintf

This commit is contained in:
Dmitry Boulytchev 2021-12-03 03:56:58 +03:00
parent 669a4288d7
commit f953814c76
3 changed files with 12 additions and 6 deletions

View file

@ -393,7 +393,7 @@ char* de_hash (int n) {
typedef struct {
char *contents;
int ptr;
int len;
int len;
} StringBuf;
static StringBuf stringBuf;
@ -421,11 +421,17 @@ static void vprintStringBuf (char *fmt, va_list args) {
int written = 0,
rest = 0;
char *buf = (char*) BOX(NULL);
va_list vsnargs;
again:
va_copy (vsnargs, args);
buf = &stringBuf.contents[stringBuf.ptr];
rest = stringBuf.len - stringBuf.ptr;
written = vsnprintf (buf, rest, fmt, args);
written = vsnprintf (buf, rest, fmt, vsnargs);
va_end(vsnargs);
if (written >= rest) {
extendStringBuf ();
@ -1219,7 +1225,7 @@ static void fix_unboxed (char *s, va_list va) {
i++;
}
s++;
}
}
}
extern void Lfailure (char *s, ...) {

View file

@ -1 +1 @@
let version = "Version 1.10, eb098a6fa, Sun Oct 31 15:34:34 2021 +0300"
let version = "Version 1.10, 669a4288d, Mon Nov 22 15:51:47 2021 +0300"

View file

@ -2,7 +2,7 @@ SHELL := /bin/bash
FILES=$(wildcard *.lama)
ALL=$(sort $(FILES:.lama=.o))
LAMAC=../src/lamac -ds
LAMAC=../src/lamac -g
all: $(ALL)