Commit 39f40473 authored by Pontus Freyhult's avatar Pontus Freyhult

* sftp_bind.c (lsftp_handle_packet): Only free(a) if free_a is

set.
(lsftp_nullcb): Init free_a to false.
(lsftp_do_stat): Explicitly clear free_a.
(lsftp_do_chown): Set free_a.
(lsftp_do_chmod): dito.
(lsftp_handle_chall): Respect free_a.

* sftp_bind.h (struct lsftp_callback): New flag, free_a.

* buffer.h: If available, include <stdint.h> and <inttypes.h>.

* sftp_c.h: Dito.

* configure.ac: Also check for stdint.h.

Rev: src/sftp/ChangeLog:1.47
Rev: src/sftp/buffer.h:1.11
Rev: src/sftp/configure.ac:1.17
Rev: src/sftp/sftp_bind.c:1.14
Rev: src/sftp/sftp_bind.h:1.8
Rev: src/sftp/sftp_c.h:1.5
parent 16caf5d0
2003-02-26 Pontus Skld <pont@soua.net>
* sftp_bind.c (lsftp_handle_packet): Only free(a) if free_a is
set.
(lsftp_nullcb): Init free_a to false.
(lsftp_do_stat): Explicitly clear free_a.
(lsftp_do_chown): Set free_a.
(lsftp_do_chmod): dito.
(lsftp_handle_chall): Respect free_a.
* sftp_bind.h (struct lsftp_callback): New flag, free_a.
* buffer.h: If available, include <stdint.h> and <inttypes.h>.
* sftp_c.h: Dito.
* configure.ac: Also check for stdint.h.
2003-02-24 Niels Mller <nisse@cuckoo.hack.org>
* rl.c (lsftp_rl_remotefile_generator): Use const char.
......
......@@ -30,11 +30,18 @@
#include "config.h"
#endif
#include <inttypes.h>
/* For off_t */
#include <sys/types.h>
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
/* Abstract input and output functions */
#include <time.h>
......
......@@ -160,7 +160,7 @@ AC_CHECK_FUNCS(pread pwrite)
# Checks for header files.
AC_CHECK_HEADERS([inttypes.h limits.h stdlib.h string.h sys/acl.h sys/file.h\
AC_CHECK_HEADERS([inttypes.h limits.h stdint.h stdlib.h string.h sys/acl.h sys/file.h\
sys/ioctl.h termios.h unistd.h glob.h memory.h errno.h fcntl.h \
readline/readline.h readline/history.h readline.h history.h\
netinet/in.h string.h sys/stat.h sys/types.h pwd.h grp.h])
......
......@@ -500,7 +500,7 @@ lsftp_handle_packet(void)
r = lsftp_cbs[j].nextfun(&state, &lsftp_cbs[j]);
/* Free any memory used */
if( lsftp_cbs[j].a )
if( lsftp_cbs[j].free_a )
free( lsftp_cbs[j].a );
if( lsftp_cbs[j].local )
......@@ -960,6 +960,7 @@ void lsftp_nullcb( struct lsftp_callback* nullcb )
nullcb->remote = 0;
nullcb->command = 0;
nullcb->a = 0;
nullcb->free_a = 0;
nullcb->memory = 0;
nullcb->opt1 = 0;
nullcb->opt2 = 0;
......@@ -2105,6 +2106,7 @@ lsftp_do_stat(const char *file, struct sftp_attrib *a)
}
l->a = a; /* Fixup attrib */
l->free_a = 0;
lsftp_safe_to_write(); /* Wait for any unsent packet to go away */
......@@ -2277,6 +2279,7 @@ lsftp_do_chown(const char *file, uint32_t uid, uint32_t gid, const char *command
if( ! attrib ) /* Malloc failed? FIXME: Report? */
return -1;
l->free_a = 1;
l->a = attrib; /* Fixup attrib */
/* Leave informational message */
l->remote = strdup( tmp );
......@@ -2340,6 +2343,7 @@ lsftp_do_chmod(const char *file, mode_t mode, const char *command)
if( ! attrib ) /* Malloc failed? FIXME: Report? */
return -1;
l->free_a = 1;
l->a = attrib; /* Fixup attrib */
/* Leave informational message */
......@@ -2377,14 +2381,18 @@ lsftp_do_chmod(const char *file, mode_t mode, const char *command)
int
lsftp_handle_stat(struct sftp_callback *s,
const struct lsftp_callback *l)
{
{
void* f;
if( s->localerr )
lsftp_perror( l->local, s->localerrno );
if( s->retval == SSH_FX_OK ) /* We should have an OK status */
{
*l->a = s->attrib;
struct sftp_attrib* p = l->a;
*p = s->attrib;
}
return s->retval;
}
......@@ -2392,7 +2400,7 @@ int
lsftp_handle_chall(struct sftp_callback *s,
const struct lsftp_callback *l)
{
if( l->a ) /* Memory for attribute? */
if( l->free_a ) /* Memory for attribute? */
free( l->a ); /* Free it */
if( s->retval != SSH_FX_OK ) /* We should have an OK status */
......
......@@ -80,7 +80,8 @@ struct lsftp_callback
int op_id;
lsftp_callback_func nextfun;
struct sftp_attrib *a;
int free_a;
const char *local;
const char *remote;
const char *command;
......
......@@ -37,11 +37,16 @@
#include <config.h>
#endif
#include <sys/types.h>
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include <sys/types.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <netinet/in.h>
#include <sys/stat.h>
#include <unistd.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment