USERADD : checks for valid username chars

This commit is contained in:
burniouf 2023-12-19 10:20:45 +01:00
parent 27a14a992b
commit 3d0a9afe6d

View File

@ -54,7 +54,6 @@ L.MSG.ROOTPWD2 .DA MSG.ROOTPWD2
L.MSG.MISMATCH .DA MSG.MISMATCH L.MSG.MISMATCH .DA MSG.MISMATCH
L.MSG.CRLF .DA MSG.CRLF L.MSG.CRLF .DA MSG.CRLF
L.MSG.BS .DA MSG.BS L.MSG.BS .DA MSG.BS
*L.ROOT .DA ROOT
J.CS.RUN.CheckArg J.CS.RUN.CheckArg
.DA CS.RUN.CheckArg.C .DA CS.RUN.CheckArg.C
.DA CS.RUN.CheckArg.D .DA CS.RUN.CheckArg.D
@ -149,7 +148,9 @@ CS.RUN.ROOT ldy #0
>PUSHBI 0 >PUSHBI 0
>SYSCALL PrintF >SYSCALL PrintF
bcs .9 bcs .9
jsr CS.RUN.GetStr jsr CS.RUN.GetStr
.90 bcs .9 .90 bcs .9
>PUSHW ZPStrPtr >PUSHW ZPStrPtr
@ -160,13 +161,8 @@ CS.RUN.ROOT ldy #0
>SYSCALL StrCmp >SYSCALL StrCmp
bcs .99 bcs .99
* jsr CS.RUN.TEST
>PUSHW pData >PUSHW pData
>SYSCALL PutPW >SYSCALL PutPW
* jsr CS.RUN.TEST
bcs .9 bcs .9
lda #0 lda #0
@ -179,33 +175,30 @@ CS.RUN.ROOT ldy #0
sec sec
rts rts
*-------------------------------------- *--------------------------------------
*CS.RUN.TEST php
* pha
* >PUSHW L.ROOT
* >PUSHWI 0
* >SYSCALL GetEnv
* phx
* >SYSCALL PutS
* pla
* >SYSCALL FreeMem
* pla
* plp
* rts
*--------------------------------------
CS.RUN.GetStr stz ZPStrLen CS.RUN.GetStr stz ZPStrLen
.1 >SYSCALL GetChar .1 >SYSCALL GetChar
bcs .9 bcs .9
cmp #C.SPACE cmp #C.SPACE
bcc .2 bcc .2
ldy ZPStrLen ldy ZPStrLen
cpy ZPStrMax cpy ZPStrMax
beq .1 beq .1
sta (ZPStrPtr),y
bit ZPbStrSecret
bmi .10
jsr CS.RUN.IsValidChar
bcs .1
.10 sta (ZPStrPtr),y
iny iny
sty ZPStrLen sty ZPStrLen
bit ZPbStrSecret bit ZPbStrSecret
bmi .1 bmi .1
>SYSCALL PutChar >SYSCALL PutChar
bra .1 bra .1
@ -214,10 +207,13 @@ CS.RUN.GetStr stz ZPStrLen
cmp #C.CR cmp #C.CR
beq .8 beq .8
cmp #C.BS cmp #C.BS
bne .1 bne .1
ldy ZPStrLen ldy ZPStrLen
beq .1 beq .1
dec ZPStrLen dec ZPStrLen
bit ZPbStrSecret bit ZPbStrSecret
bmi .1 bmi .1
@ -226,6 +222,7 @@ CS.RUN.GetStr stz ZPStrLen
>PUSHBI 0 >PUSHBI 0
>SYSCALL PrintF >SYSCALL PrintF
bra .1 bra .1
.8 ldy ZPStrLen .8 ldy ZPStrLen
lda #0 lda #0
sta (ZPStrPtr),y sta (ZPStrPtr),y
@ -233,6 +230,7 @@ CS.RUN.GetStr stz ZPStrLen
>PUSHW L.MSG.CRLF >PUSHW L.MSG.CRLF
>PUSHBI 0 >PUSHBI 0
>SYSCALL PrintF >SYSCALL PrintF
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
CS.RUN.CheckArg inc ArgIndex CS.RUN.CheckArg inc ArgIndex
@ -252,6 +250,7 @@ CS.RUN.CheckArg inc ArgIndex
.2 cmp OptionList,x .2 cmp OptionList,x
beq .3 beq .3
dex dex
bpl .2 bpl .2
@ -276,6 +275,8 @@ CS.RUN.CheckArg inc ArgIndex
adc /S.PW.DIR+11 adc /S.PW.DIR+11
sta ZPTmpPtr+1 sta ZPTmpPtr+1
stz ZPbStrSecret
ldy #0 ldy #0
.5 lda (ZPStrPtr),y .5 lda (ZPStrPtr),y
@ -283,6 +284,9 @@ CS.RUN.CheckArg inc ArgIndex
sta (ZPTmpPtr),y sta (ZPTmpPtr),y
beq .6 beq .6
jsr CS.RUN.IsValidChar
bcs CS.RUN.CheckArg.9
iny iny
cpy #16 cpy #16
bne .5 bne .5
@ -300,10 +304,11 @@ CS.RUN.CheckArg inc ArgIndex
>SYSCALL GetPWName >SYSCALL GetPWName
bcc .9 bcc .9
bra CS.RUN.CheckArg jmp CS.RUN.CheckArg
.8 lda ArgUsername .8 lda ArgUsername
beq CS.RUN.CheckArg.9 beq CS.RUN.CheckArg.9
clc clc
rts rts
@ -320,6 +325,7 @@ CS.RUN.CheckArg.P
lda ArgIndex lda ArgIndex
>SYSCALL ArgV >SYSCALL ArgV
bcs CS.RUN.CheckArg.9 bcs CS.RUN.CheckArg.9
>PUSHYA >PUSHYA
>PUSHEA.G S.PW.PASSWD >PUSHEA.G S.PW.PASSWD
>SYSCALL MD5 >SYSCALL MD5
@ -330,6 +336,7 @@ CS.RUN.CheckArg.C
lda ArgIndex lda ArgIndex
>SYSCALL ArgV >SYSCALL ArgV
bcs CS.RUN.CheckArg.9 bcs CS.RUN.CheckArg.9
ldx #S.PW.GECOS ldx #S.PW.GECOS
bra CS.RUN.CheckArg.Next bra CS.RUN.CheckArg.Next
*-------------------------------------- *--------------------------------------
@ -338,6 +345,7 @@ CS.RUN.CheckArg.D
lda ArgIndex lda ArgIndex
>SYSCALL ArgV >SYSCALL ArgV
bcs CS.RUN.CheckArg.9 bcs CS.RUN.CheckArg.9
ldx #S.PW.DIR ldx #S.PW.DIR
bra CS.RUN.CheckArg.Next bra CS.RUN.CheckArg.Next
*-------------------------------------- *--------------------------------------
@ -374,6 +382,34 @@ CS.RUN.CheckArg.Next
.8 jmp CS.RUN.CheckArg .8 jmp CS.RUN.CheckArg
*-------------------------------------- *--------------------------------------
CS.RUN.IsValidChar
cmp #'z'+1
bcs .99
cmp #'a'
bcs .8
cmp #'Z'+1
bcs .99
cmp #'A'
bcs .8
cpy #0
bcs .99
cmp #'0'
bcc .9
cmp #'9'+1
rts
.9 sec
.99 rts
.8 clc
rts
*--------------------------------------
CS.RUN.MkDir >PUSHEA.G S.PW.DIR CS.RUN.MkDir >PUSHEA.G S.PW.DIR
>PUSHWI S.STAT.MODE.RO+S.STAT.MODE.RG+S.STAT.MODE.FU >PUSHWI S.STAT.MODE.RO+S.STAT.MODE.RG+S.STAT.MODE.FU
>SYSCALL MKDir >SYSCALL MKDir
@ -391,10 +427,14 @@ CS.DOEVENT sec
*-------------------------------------- *--------------------------------------
CS.QUIT lda ZPhStr CS.QUIT lda ZPhStr
beq .1 beq .1
>SYSCALL FreeMem >SYSCALL FreeMem
.1 lda ZPhPW .1 lda ZPhPW
beq .2 beq .2
>SYSCALL FreeMem >SYSCALL FreeMem
.2 clc .2 clc
rts rts
*-------------------------------------- *--------------------------------------