diff --git a/command-not-found b/command-not-found
index 21f69a5..7693cef 100755
--- a/command-not-found
+++ b/command-not-found
@@ -86,9 +86,12 @@ def main():
help=_("don't print '<command-name>: command not found'"))
(options, args) = parser.parse_args()
if len(args) == 1:
- cnf = CommandNotFound(options.data_dir)
- if not cnf.advise(args[0], options.ignore_installed) and not options.no_failure_msg:
- print(_("%s: command not found") % args[0], file=sys.stderr)
+ if len(args[0]) > 255:
+ print(_("%s: command too long") % args[0], file=sys.stderr)
+ else:
+ cnf = CommandNotFound(options.data_dir)
+ if not cnf.advise(args[0], options.ignore_installed) and not options.no_failure_msg:
+ print(_("%s: command not found") % args[0], file=sys.stderr)
if __name__ == "__main__":
crash_guard(main, BUG_REPORT_URL, __version__)