Skip to content

Commit

Permalink
Correct the parameters to talk of "extended attributes", not SFTP ext…
Browse files Browse the repository at this point in the history
…ensions.
  • Loading branch information
Castaglia committed Nov 29, 2015
1 parent a24db7f commit f30ac3c
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions contrib/mod_sftp/fxp.c
Expand Up @@ -235,15 +235,18 @@ static size_t fxp_packet_data_allocsz = 0;
#define FXP_PACKET_DATA_DEFAULT_SZ (1024 * 16)
#define FXP_RESPONSE_DATA_DEFAULT_SZ 512

#define FXP_MAX_PACKET_LEN (1024 * 512)
#define FXP_MAX_EXTENDED_ATTRIBUTES 100

/* Maximum length of SFTP extended attribute name OR value. */
#define FXP_MAX_EXTENDED_ATTR_LEN 1024

struct fxp_extpair {
char *ext_name;
uint32_t ext_datalen;
unsigned char *ext_data;
};

/* Maximum length of SFTP extension name, AND of the extension value. */
#define SFTP_EXT_MAX_LEN 1024

static pool *fxp_pool = NULL;
static int fxp_use_gmt = TRUE;

Expand Down Expand Up @@ -1243,10 +1246,10 @@ static struct fxp_extpair *fxp_msg_read_extpair(pool *p, unsigned char **buf,
SFTP_DISCONNECT_CONN(SFTP_SSH2_DISCONNECT_BY_APPLICATION, NULL);
}

if (namelen > SFTP_EXT_MAX_LEN) {
if (namelen > FXP_MAX_EXTENDED_ATTR_LEN) {
(void) pr_log_writefile(sftp_logfd, MOD_SFTP_VERSION,
"received too-long SFTP extension name (%lu > max %lu), ignoring",
(unsigned long) namelen, (unsigned long) SFTP_EXT_MAX_LEN);
"received too-long extended attribute name (%lu > max %lu), ignoring",
(unsigned long) namelen, (unsigned long) FXP_MAX_EXTENDED_ATTR_LEN);
errno = EINVAL;
return NULL;
}
Expand All @@ -1259,10 +1262,11 @@ static struct fxp_extpair *fxp_msg_read_extpair(pool *p, unsigned char **buf,

datalen = sftp_msg_read_int(p, buf, buflen);
if (datalen > 0) {
if (datalen > SFTP_EXT_MAX_LEN) {
if (datalen > FXP_MAX_EXTENDED_ATTR_LEN) {
(void) pr_log_writefile(sftp_logfd, MOD_SFTP_VERSION,
"received too-long SFTP extension '%s' data (%lu > max %lu), ignoring",
name, (unsigned long) datalen, (unsigned long) SFTP_EXT_MAX_LEN);
"received too-long extended attribute '%s' value (%lu > max %lu), "
"ignoring", name, (unsigned long) datalen,
(unsigned long) FXP_MAX_EXTENDED_ATTR_LEN);
errno = EINVAL;
return NULL;
}
Expand Down

0 comments on commit f30ac3c

Please sign in to comment.