mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 10:40:27 +09:00
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:
@@ -40,7 +40,9 @@
|
|||||||
#include "libssh/server.h"
|
#include "libssh/server.h"
|
||||||
#include "libssh/options.h"
|
#include "libssh/options.h"
|
||||||
|
|
||||||
|
#ifndef MAX_LINE_SIZE
|
||||||
#define MAX_LINE_SIZE 1024
|
#define MAX_LINE_SIZE 1024
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Flags used for the parser state */
|
/* Flags used for the parser state */
|
||||||
#define PARSING 1
|
#define PARSING 1
|
||||||
|
|||||||
@@ -48,7 +48,9 @@
|
|||||||
#include "libssh/misc.h"
|
#include "libssh/misc.h"
|
||||||
#include "libssh/options.h"
|
#include "libssh/options.h"
|
||||||
|
|
||||||
|
#ifndef MAX_LINE_SIZE
|
||||||
#define MAX_LINE_SIZE 1024
|
#define MAX_LINE_SIZE 1024
|
||||||
|
#endif
|
||||||
|
|
||||||
struct ssh_config_keyword_table_s {
|
struct ssh_config_keyword_table_s {
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|||||||
@@ -45,6 +45,10 @@
|
|||||||
# include <arpa/inet.h>
|
# include <arpa/inet.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef MAX_LINE_SIZE
|
||||||
|
#define MAX_LINE_SIZE 4096
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup libssh_session
|
* @addtogroup libssh_session
|
||||||
*
|
*
|
||||||
@@ -74,7 +78,7 @@ static struct ssh_tokens_st *ssh_get_knownhost_line(FILE **file,
|
|||||||
const char *filename,
|
const char *filename,
|
||||||
const char **found_type)
|
const char **found_type)
|
||||||
{
|
{
|
||||||
char buffer[4096] = {0};
|
char buffer[MAX_LINE_SIZE] = {0};
|
||||||
char *ptr;
|
char *ptr;
|
||||||
struct ssh_tokens_st *tokens;
|
struct ssh_tokens_st *tokens;
|
||||||
|
|
||||||
@@ -431,7 +435,6 @@ char * ssh_dump_knownhost(ssh_session session) {
|
|||||||
ssh_key server_pubkey = NULL;
|
ssh_key server_pubkey = NULL;
|
||||||
char *host;
|
char *host;
|
||||||
char *hostport;
|
char *hostport;
|
||||||
size_t len = 4096;
|
|
||||||
char *buffer;
|
char *buffer;
|
||||||
char *b64_key;
|
char *b64_key;
|
||||||
int rc;
|
int rc;
|
||||||
@@ -467,7 +470,7 @@ char * ssh_dump_knownhost(ssh_session session) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = calloc (1, 4096);
|
buffer = calloc (1, MAX_LINE_SIZE);
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
SAFE_FREE(host);
|
SAFE_FREE(host);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -480,7 +483,7 @@ char * ssh_dump_knownhost(ssh_session session) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(buffer, len,
|
snprintf(buffer, MAX_LINE_SIZE,
|
||||||
"%s %s %s\n",
|
"%s %s %s\n",
|
||||||
host,
|
host,
|
||||||
server_pubkey->type_c,
|
server_pubkey->type_c,
|
||||||
|
|||||||
@@ -44,6 +44,10 @@
|
|||||||
#include "libssh/knownhosts.h"
|
#include "libssh/knownhosts.h"
|
||||||
#include "libssh/token.h"
|
#include "libssh/token.h"
|
||||||
|
|
||||||
|
#ifndef MAX_LINE_SIZE
|
||||||
|
#define MAX_LINE_SIZE 8192
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup libssh_session
|
* @addtogroup libssh_session
|
||||||
*
|
*
|
||||||
@@ -216,7 +220,7 @@ static int ssh_known_hosts_read_entries(const char *match,
|
|||||||
const char *filename,
|
const char *filename,
|
||||||
struct ssh_list **entries)
|
struct ssh_list **entries)
|
||||||
{
|
{
|
||||||
char line[8192];
|
char line[MAX_LINE_SIZE];
|
||||||
size_t lineno = 0;
|
size_t lineno = 0;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
@@ -895,7 +899,7 @@ int ssh_session_export_known_hosts_entry(ssh_session session,
|
|||||||
{
|
{
|
||||||
ssh_key server_pubkey = NULL;
|
ssh_key server_pubkey = NULL;
|
||||||
char *host = NULL;
|
char *host = NULL;
|
||||||
char entry_buf[4096] = {0};
|
char entry_buf[MAX_LINE_SIZE] = {0};
|
||||||
char *b64_key = NULL;
|
char *b64_key = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,10 @@
|
|||||||
#include "libssh/misc.h"
|
#include "libssh/misc.h"
|
||||||
#include "libssh/agent.h"
|
#include "libssh/agent.h"
|
||||||
|
|
||||||
|
#ifndef MAX_LINE_SIZE
|
||||||
|
#define MAX_LINE_SIZE 4096
|
||||||
|
#endif
|
||||||
|
|
||||||
#define PKCS11_URI "pkcs11:"
|
#define PKCS11_URI "pkcs11:"
|
||||||
|
|
||||||
enum ssh_keytypes_e pki_privatekey_type_from_string(const char *privkey)
|
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,
|
int ssh_pki_export_pubkey_file(const ssh_key key,
|
||||||
const char *filename)
|
const char *filename)
|
||||||
{
|
{
|
||||||
char key_buf[4096];
|
char key_buf[MAX_LINE_SIZE];
|
||||||
char host[256];
|
char host[256];
|
||||||
char *b64_key;
|
char *b64_key;
|
||||||
char *user;
|
char *user;
|
||||||
|
|||||||
Reference in New Issue
Block a user