Make the max file line length configurable

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I0bc70f4459a6eaa6f4c87887a5ee7822faf22443
This commit is contained in:
Xiang Xiao
2021-05-10 19:42:32 +08:00
committed by Jakub Jelen
parent dbe504ea0a
commit f2bd44969b
5 changed files with 22 additions and 7 deletions

View File

@@ -40,7 +40,9 @@
#include "libssh/server.h"
#include "libssh/options.h"
#ifndef MAX_LINE_SIZE
#define MAX_LINE_SIZE 1024
#endif
/* Flags used for the parser state */
#define PARSING 1

View File

@@ -48,7 +48,9 @@
#include "libssh/misc.h"
#include "libssh/options.h"
#ifndef MAX_LINE_SIZE
#define MAX_LINE_SIZE 1024
#endif
struct ssh_config_keyword_table_s {
const char *name;

View File

@@ -45,6 +45,10 @@
# include <arpa/inet.h>
#endif
#ifndef MAX_LINE_SIZE
#define MAX_LINE_SIZE 4096
#endif
/**
* @addtogroup libssh_session
*
@@ -74,7 +78,7 @@ static struct ssh_tokens_st *ssh_get_knownhost_line(FILE **file,
const char *filename,
const char **found_type)
{
char buffer[4096] = {0};
char buffer[MAX_LINE_SIZE] = {0};
char *ptr;
struct ssh_tokens_st *tokens;
@@ -431,7 +435,6 @@ char * ssh_dump_knownhost(ssh_session session) {
ssh_key server_pubkey = NULL;
char *host;
char *hostport;
size_t len = 4096;
char *buffer;
char *b64_key;
int rc;
@@ -467,7 +470,7 @@ char * ssh_dump_knownhost(ssh_session session) {
return NULL;
}
buffer = calloc (1, 4096);
buffer = calloc (1, MAX_LINE_SIZE);
if (!buffer) {
SAFE_FREE(host);
return NULL;
@@ -480,7 +483,7 @@ char * ssh_dump_knownhost(ssh_session session) {
return NULL;
}
snprintf(buffer, len,
snprintf(buffer, MAX_LINE_SIZE,
"%s %s %s\n",
host,
server_pubkey->type_c,

View File

@@ -44,6 +44,10 @@
#include "libssh/knownhosts.h"
#include "libssh/token.h"
#ifndef MAX_LINE_SIZE
#define MAX_LINE_SIZE 8192
#endif
/**
* @addtogroup libssh_session
*
@@ -216,7 +220,7 @@ static int ssh_known_hosts_read_entries(const char *match,
const char *filename,
struct ssh_list **entries)
{
char line[8192];
char line[MAX_LINE_SIZE];
size_t lineno = 0;
size_t len = 0;
FILE *fp;
@@ -895,7 +899,7 @@ int ssh_session_export_known_hosts_entry(ssh_session session,
{
ssh_key server_pubkey = NULL;
char *host = NULL;
char entry_buf[4096] = {0};
char entry_buf[MAX_LINE_SIZE] = {0};
char *b64_key = NULL;
int rc;

View File

@@ -67,6 +67,10 @@
#include "libssh/misc.h"
#include "libssh/agent.h"
#ifndef MAX_LINE_SIZE
#define MAX_LINE_SIZE 4096
#endif
#define PKCS11_URI "pkcs11:"
enum ssh_keytypes_e pki_privatekey_type_from_string(const char *privkey)
@@ -2094,7 +2098,7 @@ int ssh_pki_export_pubkey_base64(const ssh_key key,
int ssh_pki_export_pubkey_file(const ssh_key key,
const char *filename)
{
char key_buf[4096];
char key_buf[MAX_LINE_SIZE];
char host[256];
char *b64_key;
char *user;