Page 1 of 1

Exploit?

Posted: Thu Aug 04, 2011 4:55 pm
by alex

Code: Select all

(define (test) (test1))
(define (my-error-handler)    
      (println "error # " (error-text (error-number)) " has occurred\n"))
(error-event 'my-error-handler)
(test)
OS = Windows7 x64
newlisp = v.10.3.2

newlisp window closed without messages, but I have Windows messge about error.

Re: Exploit?

Posted: Thu Aug 04, 2011 7:04 pm
by Lutz
'error-number' and 'error-text' were replaced with 'last-error' in version 10.1.0, released in June 2009.

Try the following code:

Code: Select all

(define (test) (test1))
(define (my-error-handler)    
      (println (last-error)))
(error-event 'my-error-handler)
(test)
See also here: http://www.newlisp.org/downloads/newlis ... last-error
and here: http://www.newlisp.org/downloads/newlis ... rror-event

Re: Exploit?

Posted: Sat Aug 06, 2011 7:21 pm
by alex
I knew about 'error-number' and 'error-text', but why such "dramatical" :-) exit without newlisp error and with Windows error?
More precise variant, with the same exit:

Code: Select all

(define (my-error-handler) (test2))
(error-event 'my-error-handler)
(test)
Has Linux the same problem?

Re: Exploit?

Posted: Sun Aug 07, 2011 1:55 am
by Lutz
In your last example:

Code: Select all

(define (my-error-handler) (test2))
(error-event 'my-error-handler)
(test)
… the error handler itself produces an error and calls itself, causing an infinite loop, because 'test2' is not defined.

The following example:

Code: Select all

(define (my-error-handler)    
      (println (last (last-error))  " must exit")
      (exit))

(error-event 'my-error-handler)
(test)
... runs well on all platforms:

Code: Select all

~> newlisp test
ERR: invalid function : (test) must exit
~> cat test

Re: Exploit?

Posted: Sun Aug 07, 2011 1:56 am
by Lutz
In your last example:

Code: Select all

(define (my-error-handler) (test2))
(error-event 'my-error-handler)
(test)
… the error handler itself produces an error and calls itself in an infinite loop, because 'test2' is not defined.

The following example:

Code: Select all

(define (my-error-handler)    
      (println (last (last-error))  " must exit")
      (exit))

(error-event 'my-error-handler)
(test)
... runs well on all platforms:

Code: Select all

~> newlisp test
ERR: invalid function : (test) must exit
~> 

Re: Exploit?

Posted: Wed Aug 10, 2011 4:44 pm
by alex
I understand my mistake. Thanks you, Lutz.