From: jede Date: Mon, 25 Sep 2017 19:39:57 +0000 (+0200) Subject: Fixing buffer overflow with cwd command (FILENAME_MAX must be at 50 +1 bytes) X-Git-Tag: V2.17~91^2~1 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d8904c550bb7c4fabe5e80737e542aa5c88eb206;p=cc65 Fixing buffer overflow with cwd command (FILENAME_MAX must be at 50 +1 bytes) --- diff --git a/asminc/stdio.inc b/asminc/stdio.inc index 18a7541e0..3b22c47f6 100644 --- a/asminc/stdio.inc +++ b/asminc/stdio.inc @@ -47,6 +47,8 @@ FILENAME_MAX = 64+1 FILENAME_MAX = 12+1 .elseif .defined(__LUNIX__) FILENAME_MAX = 80+1 +.elseif .defined(__TELESTRAT__) +FILENAME_MAX = 50+1 .else FILENAME_MAX = 16+1 .endif diff --git a/asminc/telestrat.inc b/asminc/telestrat.inc index 48e3a9347..ffe78ad6e 100644 --- a/asminc/telestrat.inc +++ b/asminc/telestrat.inc @@ -15,7 +15,7 @@ FUNCTKEY = $A5 FNAME_LEN = 11 ; maximum length of file-name -FILENAME_MAX = 100 +FILENAME_MAX = 200 ; --------------------------------------------------------------------------- ; Zero page @@ -151,6 +151,7 @@ SCRX := $220 SCRY := $224 ADSCRL := $218 ADSCRH := $21C +IRQVECTOR := $2FA ; --------------------------------------------------------------------------- diff --git a/include/stdio.h b/include/stdio.h index c2c735cb0..a3facd513 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -75,6 +75,8 @@ extern FILE* stderr; # define FILENAME_MAX (12+1) #elif defined(__LUNIX__) # define FILENAME_MAX (80+1) +#elif defined(__TELESTRAT__) +# define FILENAME_MAX (50+1) #else # define FILENAME_MAX (16+1) #endif diff --git a/libsrc/telestrat/initcwd.s b/libsrc/telestrat/initcwd.s index df2ceb63b..f359ebeb4 100644 --- a/libsrc/telestrat/initcwd.s +++ b/libsrc/telestrat/initcwd.s @@ -1,5 +1,5 @@ ; -; Oliver Schmidt, 18.04.2005 +; Jede (jede@oric.org) 24.09.2017 ; .export initcwd @@ -10,14 +10,17 @@ initcwd: + ldx #PWD_PTR BRK_TELEMON XVARS - sta tmp1 - sty tmp1+1 - + + sta ptr1 + sty ptr1+1 + ldy #$00 + loop: - lda (tmp1),y + lda (ptr1),y beq done sta __cwd,y iny