aboutsummaryrefslogtreecommitdiffstats
path: root/erts/etc/common
diff options
context:
space:
mode:
authorMichael Santos <[email protected]>2010-10-01 19:56:52 -0400
committerBjörn Gustavsson <[email protected]>2010-10-04 15:25:22 +0200
commitb3904e7dbb9e32e8820deed8281aff97c9d141ce (patch)
treed36d1a33a14a6d9bc2dce3deebef7762e6e8b017 /erts/etc/common
parent329d7a22bdf9029a6f61a348942e2dbcd8e21de1 (diff)
downloadotp-b3904e7dbb9e32e8820deed8281aff97c9d141ce.tar.gz
otp-b3904e7dbb9e32e8820deed8281aff97c9d141ce.tar.bz2
otp-b3904e7dbb9e32e8820deed8281aff97c9d141ce.zip
typer: prevent buffer overflows
Diffstat (limited to 'erts/etc/common')
-rw-r--r--erts/etc/common/Makefile.in2
-rw-r--r--erts/etc/common/typer.c7
2 files changed, 6 insertions, 3 deletions
diff --git a/erts/etc/common/Makefile.in b/erts/etc/common/Makefile.in
index a965ac21f8..e866511153 100644
--- a/erts/etc/common/Makefile.in
+++ b/erts/etc/common/Makefile.in
@@ -339,7 +339,7 @@ $(OBJDIR)/dialyzer.o: dialyzer.c
$(CC) $(CFLAGS) -o $@ -c dialyzer.c
$(BINDIR)/typer@EXEEXT@: $(OBJDIR)/typer.o
- $(PURIFY) $(LD) $(LDFLAGS) -o $@ $(OBJDIR)/typer.o -L$(OBJDIR) $(LIBS)
+ $(PURIFY) $(LD) $(LDFLAGS) -o $@ $(OBJDIR)/typer.o -L$(OBJDIR) $(LIBS) $(ERTS_INTERNAL_LIBS)
$(OBJDIR)/typer.o: typer.c
$(CC) $(CFLAGS) -o $@ -c typer.c
diff --git a/erts/etc/common/typer.c b/erts/etc/common/typer.c
index c2567cb8b4..de48daf002 100644
--- a/erts/etc/common/typer.c
+++ b/erts/etc/common/typer.c
@@ -175,7 +175,7 @@ main(int argc, char** argv)
static void
push_words(char* src)
{
- char sbuf[1024];
+ char sbuf[MAXPATHLEN];
char* dst;
dst = sbuf;
@@ -307,7 +307,7 @@ error(char* format, ...)
va_list ap;
va_start(ap, format);
- vsprintf(sbuf, format, ap);
+ erts_vsnprintf(sbuf, sizeof(sbuf), format, ap);
va_end(ap);
fprintf(stderr, "typer: %s\n", sbuf);
exit(1);
@@ -336,6 +336,9 @@ get_default_emulator(char* progname)
char sbuf[MAXPATHLEN];
char* s;
+ if (strlen(progname) >= sizeof(sbuf))
+ return ERL_NAME;
+
strcpy(sbuf, progname);
for (s = sbuf+strlen(sbuf); s >= sbuf; s--) {
if (IS_DIRSEP(*s)) {