[tor-commits] [stem/master] Accounting for NULL access by ctypes

atagar at torproject.org atagar at torproject.org
Mon Feb 18 02:11:20 UTC 2013


commit 08529723708ed514f6f5e2489d3c1be8c0e9ae36
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Feb 17 18:09:58 2013 -0800

    Accounting for NULL access by ctypes
    
    Evidently accessing argc can raise a ValueError...
    
    https://trac.torproject.org/8266
---
 stem/util/system.py |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/stem/util/system.py b/stem/util/system.py
index c35e22f..46aead2 100644
--- a/stem/util/system.py
+++ b/stem/util/system.py
@@ -722,7 +722,15 @@ def get_process_name():
       args, argc = [], argc_t()
 
       for i in xrange(100):
-        if argc[i] is None:
+        # The ending index can be either None or raise a ValueError when
+        # accessed...
+        #
+        # ValueError: NULL pointer access
+
+        try:
+          if argc[i] is None:
+            break
+        except ValueError:
           break
 
         args.append(str(argc[i]))



More information about the tor-commits mailing list