Exploit?

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
Locked
alex
Posts: 100
Joined: Thu Mar 10, 2005 2:27 pm
Location: Russia

Exploit?

Post 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.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Exploit?

Post 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

alex
Posts: 100
Joined: Thu Mar 10, 2005 2:27 pm
Location: Russia

Re: Exploit?

Post 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?

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Exploit?

Post 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

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Exploit?

Post 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
~> 

alex
Posts: 100
Joined: Thu Mar 10, 2005 2:27 pm
Location: Russia

Re: Exploit?

Post by alex »

I understand my mistake. Thanks you, Lutz.

Locked