From: Patrick Pelletier Date: Mon, 20 Aug 2018 15:45:40 +0000 (-0700) Subject: lseek: Return EINVAL if new position is less than 0 or greater than 2^24 - 1. X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b37d0a444c4e87758ea6c8d104b6cdf11bd4c5dc;p=cc65 lseek: Return EINVAL if new position is less than 0 or greater than 2^24 - 1. Also, implemented @greg-king5's suggestion to save a byte on error paths. --- diff --git a/libsrc/apple2/lseek.s b/libsrc/apple2/lseek.s index d1633c32c..b6c31515e 100644 --- a/libsrc/apple2/lseek.s +++ b/libsrc/apple2/lseek.s @@ -22,6 +22,7 @@ _lseek: jsr popptr1 jsr popax sta ptr2 + stx ptr2+1 ; Get and process fd jsr popax @@ -78,6 +79,9 @@ seek_common: tya adc ptr2 sta mliparam + MLI::MARK::POSITION+2 + lda #$00 + adc ptr2+1 + bne einval ; less than 0 or greater than 2^24 - 1 ; Set file pointer lda #SET_MARK_CALL @@ -103,13 +107,13 @@ seek_common: einval: lda #EINVAL ; Set __errno -errno: ldx #$FF - stx sreg +errno: jsr __directerrno ; leaves -1 in AX + stx sreg ; extend return value to 32 bits stx sreg+1 - jmp __directerrno + rts ; Set __oserror -oserr: ldx #$FF - stx sreg +oserr: jsr __mappederrno ; leaves -1 in AX + stx sreg ; extend return value to 32 bits stx sreg+1 - jmp __mappederrno + rts