File 1163-Fix-ssh_connection_handler-logging-of-atoms.patch of Package erlang

From 0d223ac2e0271352181e1e1527daf7066511bca2 Mon Sep 17 00:00:00 2001
From: Jon Carstens <jjcarstens@me.com>
Date: Sun, 1 Jan 2023 14:09:38 -0700
Subject: [PATCH 1/2] Fix `ssh_connection_handler` logging of atoms

Attempting to log reasons `ssh_connection_handler` may fail if the reason
is an atom. This is because the `assure_string/1` function will return
the original `Reason0` instead of the formatted result and `io_lib.format`
can successfully format atoms, returning the original atom reason which then
fails in `string:chomp/1`

```erlang
1> io_lib:format("~s", [undef]).
"undef"
2> string:chomp(undef).
** exception error: no function clause matching string:trim_t(undef,0,{["\r\n",10],"\r\n",undefined}) (string.erl, line 885)
3>
```

This changes to return the formatted result rather than the original when
attempting to use `assure_string/1`
---
 lib/ssh/src/ssh_connection_handler.erl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/ssh/src/ssh_connection_handler.erl b/lib/ssh/src/ssh_connection_handler.erl
index 10eb5e88b4..24a3b78e72 100644
--- a/lib/ssh/src/ssh_connection_handler.erl
+++ b/lib/ssh/src/ssh_connection_handler.erl
@@ -1903,7 +1903,7 @@ do_log(F, Reason0, #data{ssh_params=S}) ->
 
 assure_string(S) ->
     try io_lib:format("~s",[S])
-    of _ -> S
+    of Formatted -> Formatted
     catch
         _:_ -> io_lib:format("~p",[S])
     end.
-- 
2.35.3

openSUSE Build Service is sponsored by