1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-30 13:01:23 +03:00

misc: Add a function to encode newlines

Given a string, the added function encodes existing newline characters
('\n') as the string "\\n" and puts into a given output buffer.

The output buffer must have at least 2 times the length of the input
string plus 1 for the terminating '\0'. In the worst case, each
character can be replaced by 2 characters.

Fixes T189

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
Anderson Toshiyuki Sasaki
2019-11-04 15:35:15 +01:00
committed by Andreas Schneider
parent 6c79ed9801
commit c9ce8fa40b
3 changed files with 63 additions and 0 deletions

View File

@@ -95,5 +95,6 @@ void ssh_log_hexdump(const char *descr, const unsigned char *what, size_t len);
int ssh_mkdirs(const char *pathname, mode_t mode);
int ssh_quote_file_name(const char *file_name, char *buf, size_t buf_len);
int ssh_newline_vis(const char *string, char *buf, size_t buf_len);
#endif /* MISC_H_ */