mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Check for invalid output file. Fixes #3066
This commit is contained in:
@@ -236,7 +236,7 @@ class NmapOutputViewer(Gtk.Box):
|
|||||||
self.text_view.get_buffer().set_text(output)
|
self.text_view.get_buffer().set_text(output)
|
||||||
self.apply_highlighting()
|
self.apply_highlighting()
|
||||||
except MemoryError:
|
except MemoryError:
|
||||||
self.show_large_output_message(self.command_execution)
|
self.show_large_output_message()
|
||||||
|
|
||||||
def set_command_execution(self, command):
|
def set_command_execution(self, command):
|
||||||
"""Set the live running command whose output is shown by this display.
|
"""Set the live running command whose output is shown by this display.
|
||||||
@@ -249,8 +249,9 @@ class NmapOutputViewer(Gtk.Box):
|
|||||||
self.output_file_pointer = None
|
self.output_file_pointer = None
|
||||||
self.refresh_output()
|
self.refresh_output()
|
||||||
|
|
||||||
def show_large_output_message(self, command=None):
|
def replace_buffer_warning_message(self, message):
|
||||||
buf = self.text_view.get_buffer()
|
buf = self.text_view.get_buffer()
|
||||||
|
command = self.command_execution
|
||||||
try:
|
try:
|
||||||
running = (command is not None and command.scan_state() is True)
|
running = (command is not None and command.scan_state() is True)
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -259,20 +260,22 @@ class NmapOutputViewer(Gtk.Box):
|
|||||||
else:
|
else:
|
||||||
complete = not running
|
complete = not running
|
||||||
if running:
|
if running:
|
||||||
buf.set_text("Warning: You have insufficient resources for Zenmap "
|
buf.set_text(_("Warning: %s \n"
|
||||||
"to be able to display the complete output from Nmap here. \n"
|
|
||||||
"Zenmap will continue to run the scan to completion. However,"
|
"Zenmap will continue to run the scan to completion. However,"
|
||||||
" some features of Zenmap might not work as expected.")
|
" some features of Zenmap might not work as expected."))
|
||||||
elif complete:
|
elif complete:
|
||||||
buf.set_text("Warning: You have insufficient resources for Zenmap "
|
buf.set_text(_("Warning: %s \n"
|
||||||
"to be able to display the complete output from Nmap here. \n"
|
|
||||||
"The scan has completed. However, some features of Zenmap "
|
"The scan has completed. However, some features of Zenmap "
|
||||||
"might not work as expected.")
|
"might not work as expected."))
|
||||||
else:
|
else:
|
||||||
buf.set_text("Warning: You have insufficient resources for Zenmap "
|
buf.set_text(_("Warning: %s \n"
|
||||||
"to be able to display the complete output from Nmap here. \n"
|
|
||||||
"The scan has been stopped. Some features of Zenmap might not "
|
"The scan has been stopped. Some features of Zenmap might not "
|
||||||
"work as expected.")
|
"work as expected."))
|
||||||
|
|
||||||
|
def show_large_output_message(self):
|
||||||
|
self.replace_buffer_warning_message(
|
||||||
|
_("You have insufficient resources for Zenmap to be able to "
|
||||||
|
"display the complete output from Nmap here. \n"))
|
||||||
|
|
||||||
def refresh_output(self, widget=None):
|
def refresh_output(self, widget=None):
|
||||||
"""Update the output from the latest output of the command associated
|
"""Update the output from the latest output of the command associated
|
||||||
@@ -284,12 +287,17 @@ class NmapOutputViewer(Gtk.Box):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Seek to the end of the most recent read.
|
# Seek to the end of the most recent read.
|
||||||
|
try:
|
||||||
self.command_execution.stdout_file.seek(self.output_file_pointer)
|
self.command_execution.stdout_file.seek(self.output_file_pointer)
|
||||||
|
except ValueError:
|
||||||
|
self.replace_buffer_warning_message(
|
||||||
|
_("The Nmap output file has been closed unexpectedly."))
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
new_output = self.command_execution.stdout_file.read()
|
new_output = self.command_execution.stdout_file.read()
|
||||||
except MemoryError:
|
except MemoryError:
|
||||||
self.show_large_output_message(self.command_execution)
|
self.show_large_output_message()
|
||||||
return
|
return
|
||||||
|
|
||||||
self.output_file_pointer = self.command_execution.stdout_file.tell()
|
self.output_file_pointer = self.command_execution.stdout_file.tell()
|
||||||
@@ -309,7 +317,7 @@ class NmapOutputViewer(Gtk.Box):
|
|||||||
buf.get_iter_at_mark(prev_end_mark),
|
buf.get_iter_at_mark(prev_end_mark),
|
||||||
buf.get_end_iter())
|
buf.get_end_iter())
|
||||||
except MemoryError:
|
except MemoryError:
|
||||||
self.show_large_output_message(self.command_execution)
|
self.show_large_output_message()
|
||||||
return
|
return
|
||||||
|
|
||||||
if at_end:
|
if at_end:
|
||||||
|
|||||||
Reference in New Issue
Block a user