Skip to content

Commit

Permalink
Issue #1792: Use the new pr_fsio_realpath() function implemented in…
Browse files Browse the repository at this point in the history
… Issue #1780 in the `statvfs(2)` system calls in mod_sftp. (#1795)
  • Loading branch information
Castaglia committed Apr 20, 2024
1 parent c22345a commit 4f131c6
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions contrib/mod_sftp/fxp.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* ProFTPD - mod_sftp sftp
* Copyright (c) 2008-2023 TJ Saunders
* Copyright (c) 2008-2024 TJ Saunders
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -5647,9 +5647,10 @@ static off_t get_user_bytes_unused(void *ptr) {
return ((off_t) fs->f_bavail * (off_t) fs->f_frsize);
}

static int fxp_handle_ext_space_avail(struct fxp_packet *fxp, char *path) {
static int fxp_handle_ext_space_avail(struct fxp_packet *fxp,
const char *path) {
unsigned char *buf, *ptr;
const char *reason;
const char *real_path = NULL, *reason;
uint32_t buflen, bufsz, status_code;
struct fxp_packet *resp;

Expand All @@ -5674,6 +5675,11 @@ static int fxp_handle_ext_space_avail(struct fxp_packet *fxp, char *path) {
buflen = bufsz = FXP_RESPONSE_DATA_DEFAULT_SZ;
buf = ptr = palloc(fxp->pool, bufsz);

real_path = pr_fsio_realpath(fxp->pool, path);
if (real_path != NULL) {
path = real_path;
}

if (statvfs(path, &fs) < 0) {
int xerrno = errno;

Expand Down Expand Up @@ -5725,7 +5731,7 @@ static int fxp_handle_ext_space_avail(struct fxp_packet *fxp, char *path) {

static int fxp_handle_ext_statvfs(struct fxp_packet *fxp, const char *path) {
unsigned char *buf, *ptr;
const char *reason;
const char *real_path = NULL, *reason;
uint32_t buflen, bufsz, status_code;
struct fxp_packet *resp;
uint64_t fs_id = 0, fs_flags = 0;
Expand All @@ -5748,6 +5754,11 @@ static int fxp_handle_ext_statvfs(struct fxp_packet *fxp, const char *path) {
buflen = bufsz = FXP_RESPONSE_DATA_DEFAULT_SZ;
buf = ptr = palloc(fxp->pool, bufsz);

real_path = pr_fsio_realpath(fxp->pool, path);
if (real_path != NULL) {
path = real_path;
}

if (statvfs(path, &fs) < 0) {
int xerrno = errno;

Expand Down Expand Up @@ -7369,7 +7380,7 @@ static int fxp_handle_extended(struct fxp_packet *fxp) {
#if defined(HAVE_SYS_STATVFS_H)
if ((fxp_ext_flags & SFTP_FXP_EXT_SPACE_AVAIL) &&
strcmp(ext_request_name, "space-available") == 0) {
char *path;
const char *path;

path = sftp_msg_read_string(fxp->pool, &fxp->payload, &fxp->payload_sz);

Expand Down

0 comments on commit 4f131c6

Please sign in to comment.