Exploit?

Started by alex, August 04, 2011, 09:55:37 AM

Previous topic - Next topic

alex

(define (test) (test1))
(define (my-error-handler)    
      (println "error # " (error-text (error-number)) " has occurredn"))
(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.

Lutz

#1
'error-number' and 'error-text' were replaced with 'last-error' in version 10.1.0, released in June 2009.



Try the following code:


(define (test) (test1))
(define (my-error-handler)    
      (println (last-error)))
(error-event 'my-error-handler)
(test)


See also here: http://www.newlisp.org/downloads/newlisp_manual.html#last-error">http://www.newlisp.org/downloads/newlis ... last-error">http://www.newlisp.org/downloads/newlisp_manual.html#last-error

and here: http://www.newlisp.org/downloads/newlisp_manual.html#error-event">http://www.newlisp.org/downloads/newlis ... rror-event">http://www.newlisp.org/downloads/newlisp_manual.html#error-event

alex

#2
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:
(define (my-error-handler) (test2))
(error-event 'my-error-handler)
(test)

Has Linux the same problem?

Lutz

#3
In your last example:


(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:
(define (my-error-handler)    
      (println (last (last-error))  " must exit")
      (exit))

(error-event 'my-error-handler)
(test)

... runs well on all platforms:
~> newlisp test
ERR: invalid function : (test) must exit
~> cat test

Lutz

#4
In your last example:


(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:
(define (my-error-handler)    
      (println (last (last-error))  " must exit")
      (exit))

(error-event 'my-error-handler)
(test)

... runs well on all platforms:
~> newlisp test
ERR: invalid function : (test) must exit
~>

alex

#5
I understand my mistake. Thanks you, Lutz.