}
smb_encrypt = get_cmdline_auth_info_smb_encrypt();
- init_names();
+ if (!init_names()) {
+ fprintf(stderr, "init_names() failed\n");
+ exit(1);
+ }
if(new_name_resolve_order)
lp_set_name_resolve_order(new_name_resolve_order);
#include "librpc/gen_ndr/cli_dssetup.h"
#include "librpc/gen_ndr/cli_ntsvcs.h"
+#define prs_init_empty( _ps_, _ctx_, _io_ ) (void) prs_init((_ps_), 0, (_ctx_), (_io_))
+
/* macro to expand cookie-cutter code in cli_xxx() using rpc_api_pipe_req() */
#define CLI_DO_RPC_INTERNAL( pcli, ctx, p_idx, opnum, q_in, r_out, \
if (!prs_init( &q_ps, RPC_MAX_PDU_FRAG_LEN, ctx, MARSHALL )) { \
return NT_STATUS_NO_MEMORY;\
}\
- if (!prs_init( &r_ps, 0, ctx, UNMARSHALL )) {\
- prs_mem_free( &q_ps );\
- return NT_STATUS_NO_MEMORY;\
- }\
+ prs_init_empty( &r_ps, ctx, UNMARSHALL );\
if ( copy_sess_key) prs_set_session_key(&q_ps, (const char *)pcli->dc->sess_key);\
if ( q_io_fn("", &q_in, &q_ps, 0) ) {\
NTSTATUS _smb_pipe_stat_ = rpc_api_pipe_req(pcli, opnum, &q_ps, &r_ps); \
if (!prs_init( &q_ps, RPC_MAX_PDU_FRAG_LEN, ctx, MARSHALL )) { \
return WERR_NOMEM;\
}\
- if (!prs_init( &r_ps, 0, ctx, UNMARSHALL )) {\
- prs_mem_free( &q_ps );\
- return WERR_NOMEM;\
- }\
+ prs_init_empty( &r_ps, ctx, UNMARSHALL );\
if ( q_io_fn("", &q_in, &q_ps, 0) ) {\
NTSTATUS _smb_pipe_stat_ = rpc_api_pipe_req(pcli, opnum, &q_ps, &r_ps); \
if (!NT_STATUS_IS_OK(_smb_pipe_stat_)) {\
#endif
sock2.sin_family = PF_INET;
- bind(listener, (struct sockaddr *)&sock2, sizeof(sock2));
+ if (bind(listener, (struct sockaddr *)&sock2, sizeof(sock2)) != 0) goto failed;
if (listen(listener, 1) != 0) goto failed;
krb5_principal princ = NULL;
char *princ_s = NULL;
char *unparsed_name = NULL;
+ krb5_error_code code;
- krb5_init_context(&context);
- if (!context) {
+ if (((code = krb5_init_context(&context)) != 0) || (context == NULL)) {
+ DEBUG(5, ("kerberos_secrets_store_salting_pricipal: kdb5_init_context failed: %s\n",
+ error_message(code)));
return False;
}
if (strchr_m(service, '@')) {
return ADS_ERROR_SYSTEM(rc);
}
addr_len = sizeof(remote_addr);
- getpeername(sock, (struct sockaddr *)&remote_addr, &addr_len);
+ if (getpeername(sock, (struct sockaddr *)&remote_addr, &addr_len) != 0) {
+ close(sock);
+ SAFE_FREE(ap_req.data);
+ krb5_auth_con_free(context, auth_context);
+ DEBUG(1,("getpeername() failed (%s)\n", error_message(errno)));
+ return ADS_ERROR_SYSTEM(errno);
+ }
addr_len = sizeof(local_addr);
- getsockname(sock, (struct sockaddr *)&local_addr, &addr_len);
-
+ if (getsockname(sock, (struct sockaddr *)&local_addr, &addr_len) != 0) {
+ close(sock);
+ SAFE_FREE(ap_req.data);
+ krb5_auth_con_free(context, auth_context);
+ DEBUG(1,("getsockname() failed (%s)\n", error_message(errno)));
+ return ADS_ERROR_SYSTEM(errno);
+ }
if (!setup_kaddr(&remote_kaddr, &remote_addr) ||
!setup_kaddr(&local_kaddr, &local_addr)) {
DEBUG(1,("do_krb5_kpasswd_request: "
if (!values) return NULL;
for (i=0; in_vals[i]; i++) {
- push_utf8_talloc(ctx, &values[i], in_vals[i]);
+ if (push_utf8_talloc(ctx, &values[i], in_vals[i]) == (size_t) -1) {
+ TALLOC_FREE(values);
+ return NULL;
+ }
}
return values;
}
if (res == -1)
return -1;
- setsockopt(res,SOL_SOCKET,SO_REUSEADDR,(char *)&val,sizeof(val));
+ if (setsockopt(res,SOL_SOCKET,SO_REUSEADDR,(char *)&val,sizeof(val)) != 0) {
+ close(res);
+ return -1;
+ }
#ifdef SO_REUSEPORT
- setsockopt(res,SOL_SOCKET,SO_REUSEPORT,(char *)&val,sizeof(val));
+ if (setsockopt(res,SOL_SOCKET,SO_REUSEPORT,(char *)&val,sizeof(val)) != 0) {
+ close(res);
+ return -1;
+ }
#endif /* SO_REUSEPORT */
/* now we've got a socket - we need to bind it */
return NT_STATUS_UNSUCCESSFUL;
}
- ber_printf (ber, "{");
- ber_printf (ber, "ts", LDAP_TAG_EXOP_MODIFY_PASSWD_ID, utf8_dn);
- ber_printf (ber, "ts", LDAP_TAG_EXOP_MODIFY_PASSWD_NEW, utf8_password);
- ber_printf (ber, "n}");
+ if ((ber_printf (ber, "{") < 0) ||
+ (ber_printf (ber, "ts", LDAP_TAG_EXOP_MODIFY_PASSWD_ID, utf8_dn) < 0) ||
+ (ber_printf (ber, "ts", LDAP_TAG_EXOP_MODIFY_PASSWD_NEW, utf8_password) < 0) ||
+ (ber_printf (ber, "n}") < 0)) {
+ DEBUG(0,("ldapsam_modify_entry: ber_printf returns a value <0\n"));
+ ber_free(ber,1);
+ SAFE_FREE(utf8_dn);
+ SAFE_FREE(utf8_password);
+ return NT_STATUS_UNSUCCESSFUL;
+ }
if ((rc = ber_flatten (ber, &bv))<0) {
DEBUG(0,("ldapsam_modify_entry: ber_flatten returns a value <0\n"));
/* set remaining fields */
- pdb_set_nt_passwd (sam_pass, pw_buf->smb_nt_passwd, PDB_SET);
- pdb_set_lanman_passwd (sam_pass, pw_buf->smb_passwd, PDB_SET);
+ if (!pdb_set_nt_passwd (sam_pass, pw_buf->smb_nt_passwd, PDB_SET))
+ return False;
+ if (!pdb_set_lanman_passwd (sam_pass, pw_buf->smb_passwd, PDB_SET))
+ return False;
pdb_set_acct_ctrl (sam_pass, pw_buf->acct_ctrl, PDB_SET);
pdb_set_pass_last_set_time (sam_pass, pw_buf->pass_last_set_time, PDB_SET);
pdb_set_pass_can_change_time (sam_pass, pw_buf->pass_last_set_time, PDB_SET);
ZERO_STRUCT( ps );
- prs_init( &ps, 0, ctx, UNMARSHALL );
+ prs_init_empty( &ps, ctx, UNMARSHALL );
prs_give_memory( &ps, (char *)data.dptr, data.dsize, False );
if ( !sec_io_desc_buf( "sec_desc_upg_fn", &sd_orig, &ps, 1 ) ) {
/* create a new SEC_DESC with the appropriate owner and group SIDs */
- string_to_sid(&sid, "S-1-5-32-544" );
+ if (!string_to_sid(&sid, "S-1-5-32-544" )) {
+ prs_mem_free( &ps );
+ return 0;
+ }
new_sec = make_sec_desc( ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE,
&sid, &sid,
NULL, NULL, &size_new_sec );
sd_size = ndr_size_security_descriptor(sd_store->sd, 0)
+ sizeof(SEC_DESC_BUF);
- prs_init(&ps, sd_size, ctx, MARSHALL);
+ if ( !prs_init(&ps, sd_size, ctx, MARSHALL) ) {
+ DEBUG(0,("sec_desc_upg_fn: Failed to allocate prs memory for %s\n", key.dptr ));
+ return 0;
+ }
if ( !sec_io_desc_buf( "sec_desc_upg_fn", &sd_store, &ps, 1 ) ) {
DEBUG(0,("sec_desc_upg_fn: Failed to parse new sec_desc for %s\n", key.dptr ));
ZERO_STRUCT(devmode);
- prs_init(&ps, 0, ctx, UNMARSHALL);
+ prs_init_empty(&ps, ctx, UNMARSHALL);
ps.data_p = (char *)data;
ps.buffer_size = data_len;
/* Store the security descriptor in a tdb */
- prs_init(&ps,
- (uint32)ndr_size_security_descriptor(new_secdesc_ctr->sd, 0)
- + sizeof(SEC_DESC_BUF), mem_ctx, MARSHALL);
+ if (!prs_init(&ps,
+ (uint32)ndr_size_security_descriptor(new_secdesc_ctr->sd, 0)
+ + sizeof(SEC_DESC_BUF), mem_ctx, MARSHALL) ) {
+ status = WERR_NOMEM;
+ goto out;
+ }
+
prs_init_done = true;
/* Save default security descriptor for later */
- prs_init(&ps, (uint32)ndr_size_security_descriptor((*secdesc_ctr)->sd, 0) +
- sizeof(SEC_DESC_BUF), ctx, MARSHALL);
+ if (!prs_init(&ps, (uint32)ndr_size_security_descriptor((*secdesc_ctr)->sd, 0) +
+ sizeof(SEC_DESC_BUF), ctx, MARSHALL))
+ return False;
if (sec_io_desc_buf("nt_printing_getsec", secdesc_ctr, &ps, 1)) {
tdb_prs_store(tdb_printers, kbuf, &ps);
/* use a prs_struct for converting the devmode and security
descriptor to REG_BINARY */
- prs_init( &prs, RPC_MAX_PDU_FRAG_LEN, values, MARSHALL);
+ if (!prs_init( &prs, RPC_MAX_PDU_FRAG_LEN, values, MARSHALL))
+ return;
/* stream the device mode */
return -1;
}
- prs_init( ps, block_size, file->mem_ctx, UNMARSHALL );
+ if (!prs_init( ps, block_size, file->mem_ctx, UNMARSHALL )) {
+ DEBUG(0,("read_block: prs_init() failed! (%s)\n", strerror(errno) ));
+ return -1;
+ }
buffer = prs_data_p( ps );
bytes_read = returned = 0;
/* Common case. */
if (current_pdu_len == (uint32)prhdr->frag_len) {
prs_mem_free(current_pdu);
- prs_init(current_pdu, 0, prs_get_mem_context(current_pdu), UNMARSHALL);
+ prs_init_empty(current_pdu, prs_get_mem_context(current_pdu), UNMARSHALL);
/* Make current_pdu dynamic with no memory. */
prs_give_memory(current_pdu, 0, 0, True);
return NT_STATUS_OK;
#endif
/* Set up the current pdu parse struct. */
- prs_init(¤t_pdu, 0, prs_get_mem_context(rbuf), UNMARSHALL);
+ prs_init_empty(¤t_pdu, prs_get_mem_context(rbuf), UNMARSHALL);
/* Create setup parameters - must be in native byte order. */
setup[0] = TRANSACT_DCERPCCMD;
NTSTATUS ret = NT_STATUS_OK;
ZERO_STRUCT(hdr_auth);
- prs_init(&auth_info, RPC_HDR_AUTH_LEN, prs_get_mem_context(rpc_out), MARSHALL);
+ if (!prs_init(&auth_info, RPC_HDR_AUTH_LEN, prs_get_mem_context(rpc_out), MARSHALL))
+ return NT_STATUS_NO_MEMORY;
switch (auth_type) {
case PIPE_AUTH_TYPE_SCHANNEL:
return NT_STATUS_INVALID_PARAMETER;
}
- prs_init(&outgoing_pdu, cli->max_xmit_frag, prs_get_mem_context(in_data), MARSHALL);
+ if (!prs_init(&outgoing_pdu, cli->max_xmit_frag, prs_get_mem_context(in_data), MARSHALL))
+ return NT_STATUS_NO_MEMORY;
while (1) {
RPC_HDR hdr;
return nt_status;
}
- prs_init(&rpc_out, 0, prs_get_mem_context(rbuf), MARSHALL);
+ prs_init_empty(&rpc_out, prs_get_mem_context(rbuf), MARSHALL);
nt_status = create_rpc_bind_auth3(cli, rpc_call_id,
auth_type, auth_level,
NTSTATUS ret = NT_STATUS_OK;
ZERO_STRUCT(hdr_auth);
- prs_init(&auth_info, RPC_HDR_AUTH_LEN, prs_get_mem_context(rpc_out), MARSHALL);
+ if (!prs_init(&auth_info, RPC_HDR_AUTH_LEN, prs_get_mem_context(rpc_out), MARSHALL))
+ return NT_STATUS_NO_MEMORY;
/* We may change the pad length before marshalling. */
init_rpc_hdr_auth(&hdr_auth, RPC_SPNEGO_AUTH_TYPE, (int)auth_level, 0, 1);
tmp_blob = data_blob_null; /* Ensure it's safe to free this just in case. */
/* Now prepare the alter context pdu. */
- prs_init(&rpc_out, 0, prs_get_mem_context(rbuf), MARSHALL);
+ prs_init_empty(&rpc_out, prs_get_mem_context(rbuf), MARSHALL);
nt_status = create_rpc_alter_context(rpc_call_id,
abstract,
/* Initialize the returning data struct. */
prs_mem_free(rbuf);
- prs_init(rbuf, 0, cli->mem_ctx, UNMARSHALL);
+ prs_init_empty(rbuf, cli->mem_ctx, UNMARSHALL);
nt_status = rpc_api_pipe(cli, &rpc_out, rbuf, RPC_ALTCONTRESP);
if (!NT_STATUS_IS_OK(nt_status)) {
return NT_STATUS_INVALID_PARAMETER;
}
- prs_init(&rpc_out, 0, cli->mem_ctx, MARSHALL);
+ prs_init_empty(&rpc_out, cli->mem_ctx, MARSHALL);
rpc_call_id = get_rpc_call_id();
}
/* Initialize the incoming data struct. */
- prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
+ prs_init_empty(&rbuf, cli->mem_ctx, UNMARSHALL);
/* send data on \PIPE\. receive a response */
status = rpc_api_pipe(cli, &rpc_out, &rbuf, RPC_BINDACK);
talloc_free(push);
- if (!prs_init( &r_ps, 0, mem_ctx, UNMARSHALL )) {
- prs_mem_free( &q_ps );
- return NT_STATUS_NO_MEMORY;
- }
+ prs_init_empty( &r_ps, mem_ctx, UNMARSHALL );
status = rpc_api_pipe_req(cli, opnum, &q_ps, &r_ps);
{
buffer->size = size;
buffer->string_at_end = size;
- prs_init(&buffer->prs, size, ctx, MARSHALL);
- buffer->struct_start = prs_offset(&buffer->prs);
+ if (prs_init(&buffer->prs, size, ctx, MARSHALL))
+ buffer->struct_start = prs_offset(&buffer->prs);
+ else
+ buffer->struct_start = NULL;
}
/*******************************************************************
prs_debug(ps, depth, desc, "smb_io_strhdr");
depth++;
- prs_align(ps);
+ if(!prs_align(ps))
+ return False;
if(!prs_uint16("str_str_len", ps, depth, &hdr->str_str_len))
return False;
prs_debug(ps, depth, desc, "smb_io_bufhdr2");
depth++;
- prs_align(ps);
- prs_uint32("info_level", ps, depth, &(hdr->info_level));
- prs_uint32("length ", ps, depth, &(hdr->length ));
- prs_uint32("buffer ", ps, depth, &(hdr->buffer ));
+ if (!prs_align(ps))
+ return False;
+ if (!prs_uint32("info_level", ps, depth, &(hdr->info_level)))
+ return False;
+ if (!prs_uint32("length ", ps, depth, &(hdr->length )))
+ return False;
+ if (!prs_uint32("buffer ", ps, depth, &(hdr->buffer )))
+ return False;
return True;
}
prs_debug(ps, depth, desc, "smb_io_bufhdr4");
depth++;
- prs_align(ps);
- prs_uint32("size", ps, depth, &hdr->size);
- prs_uint32("buffer", ps, depth, &hdr->buffer);
+ if (!prs_align(ps))
+ return False;
+ if (!prs_uint32("size", ps, depth, &hdr->size))
+ return False;
+ if (!prs_uint32("buffer", ps, depth, &hdr->buffer))
+ return False;
return True;
}
prs_debug(ps, depth, desc, "smb_io_rpc_blob");
depth++;
- prs_align(ps);
+ if (!prs_align(ps))
+ return False;
if ( !prs_uint32("buf_len", ps, depth, &blob->buf_len) )
return False;
{
TDB_DATA dbuf;
- prs_init(ps, 0, mem_ctx, UNMARSHALL);
+ prs_init_empty(ps, mem_ctx, UNMARSHALL);
dbuf = tdb_fetch(tdb, kbuf);
if (!dbuf.dptr)
* data.
*/
- prs_init( &outgoing_pdu, 0, p->mem_ctx, MARSHALL);
+ prs_init_empty( &outgoing_pdu, p->mem_ctx, MARSHALL);
prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False);
/* Store the header in the data stream. */
* data.
*/
- prs_init( &outgoing_pdu, 0, p->mem_ctx, MARSHALL);
+ prs_init_empty( &outgoing_pdu, p->mem_ctx, MARSHALL);
prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False);
/* Store the header in the data stream. */
* data.
*/
- prs_init( &outgoing_pdu, 0, p->mem_ctx, MARSHALL);
+ prs_init_empty( &outgoing_pdu, p->mem_ctx, MARSHALL);
prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False);
/* Store the header in the data stream. */
* header and are never sending more than one PDU here.
*/
- prs_init( &outgoing_rpc, 0, p->mem_ctx, MARSHALL);
+ prs_init_empty( &outgoing_rpc, p->mem_ctx, MARSHALL);
prs_give_memory( &outgoing_rpc, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False);
/*
* header and are never sending more than one PDU here.
*/
- prs_init( &outgoing_pdu, 0, p->mem_ctx, MARSHALL);
+ prs_init_empty( &outgoing_pdu, p->mem_ctx, MARSHALL);
prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False);
/*
* header and are never sending more than one PDU here.
*/
- prs_init( &outgoing_pdu, 0, p->mem_ctx, MARSHALL);
+ prs_init_empty( &outgoing_pdu, p->mem_ctx, MARSHALL);
prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False);
/*
return setup_bind_nak(p);
}
- prs_init( &outgoing_rpc, 0, p->mem_ctx, MARSHALL);
+ prs_init_empty( &outgoing_rpc, p->mem_ctx, MARSHALL);
/*
* Marshall directly into the outgoing PDU space. We
prs_struct outgoing_rpc;
int auth_len = 0;
- prs_init( &outgoing_rpc, 0, p->mem_ctx, MARSHALL);
+ prs_init_empty( &outgoing_rpc, p->mem_ctx, MARSHALL);
/*
* Marshall directly into the outgoing PDU space. We
/*
* Initialize the outgoing RPC data buffer with no memory.
*/
- prs_init(&p->out_data.rdata, 0, p->mem_ctx, MARSHALL);
+ prs_init_empty(&p->out_data.rdata, p->mem_ctx, MARSHALL);
fstrcpy(p->name, pipe_name);
return -1;
}
- prs_init( &rpc_in, 0, p->mem_ctx, UNMARSHALL);
+ prs_init_empty( &rpc_in, p->mem_ctx, UNMARSHALL);
prs_set_endian_data( &rpc_in, p->endian);
prs_give_memory( &rpc_in, (char *)&p->in_data.current_in_pdu[0],
return;
}
- prs_init( &rpc_in, 0, p->mem_ctx, UNMARSHALL);
+ prs_init_empty( &rpc_in, p->mem_ctx, UNMARSHALL);
/*
* Ensure we're using the corrent endianness for both the
/* NT seems to like setting the security descriptor even though
nothing may have actually changed. */
- nt_printing_getsec(p->mem_ctx, Printer->sharename, &old_secdesc_ctr);
+ if ( !nt_printing_getsec(p->mem_ctx, Printer->sharename, &old_secdesc_ctr)) {
+ DEBUG(2,("update_printer_sec: nt_printing_getsec() failed\n"));
+ result = WERR_BADFID;
+ goto done;
+ }
if (DEBUGLEVEL >= 10) {
SEC_ACL *the_acl;
if(regkey->key->type == REG_KEY_HKPD)
{
if(strequal(r->in.value_name.name, "Global")) {
- prs_init(&prs_hkpd, *r->in.data_size, p->mem_ctx, MARSHALL);
+ if (!prs_init(&prs_hkpd, *r->in.data_size, p->mem_ctx, MARSHALL))
+ return WERR_NOMEM;
status = reg_perfcount_get_hkpd(
&prs_hkpd, *r->in.data_size, &outbuf_size, NULL);
outbuf = (uint8_t *)prs_hkpd.data_p;
else if(isdigit(r->in.value_name.name[0])) {
/* we probably have a request for a specific object
* here */
- prs_init(&prs_hkpd, *r->in.data_size, p->mem_ctx, MARSHALL);
+ if (!prs_init(&prs_hkpd, *r->in.data_size, p->mem_ctx, MARSHALL))
+ return WERR_NOMEM;
status = reg_perfcount_get_hkpd(
&prs_hkpd, *r->in.data_size, &outbuf_size,
r->in.value_name.name);
}
/* stream the printer security descriptor */
- prs_init( &ps, RPC_MAX_PDU_FRAG_LEN, key, MARSHALL);
+
+ if (!prs_init( &ps, RPC_MAX_PDU_FRAG_LEN, key, MARSHALL)) {
+ DEBUG(0,("svcctl_set_secdesc: prs_init() failed!\n"));
+ TALLOC_FREE( key );
+ return False;
+ }
if ( sec_io_desc("sec_desc", &sec_desc, &ps, 0 ) ) {
uint32 offset = prs_offset( &ps );
return;
}
- prs_init(&ps, 0, NULL, MARSHALL);
+ prs_init_empty(&ps, NULL, MARSHALL);
if (!notify_marshall_changes(notify_buf->num_changes, max_param,
notify_buf->changes, &ps)) {
void become_root(void)
{
- push_sec_ctx();
+ /*
+ * no good way to handle push_sec_ctx() failing without changing
+ * the prototype of become_root()
+ */
+ if (!push_sec_ctx())
+ return;
push_conn_ctx();
set_root_sec_ctx();
}
rpccli_samr_Close(pipe_hnd, mem_ctx, &domain_pol);
- string_to_sid(&sid_Builtin, "S-1-5-32");
+ (void) string_to_sid(&sid_Builtin, "S-1-5-32");
result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
&connect_pol,
return False;
}
- string_to_sid(&user_sid, response.data.sid.sid);
+ if (!string_to_sid(&user_sid, response.data.sid.sid)) {
+ DEBUG(1, ("Could not convert string '%s' to SID\n", response.data.sid.sid));
+ return False;
+ }
init_user_token(token, &user_sid);
ctx=talloc_init("main");
if (!ctx) exit(1);
- prs_init(&ps, 1600, 4, ctx, MARSHALL);
+ if (!prs_init(&ps, 1600, 4, ctx, MARSHALL))
+ exit(1);
while (scanf("%s", s)!=-1) {
if (strlen(s)==2 && strchr_m(filter, *s)!=NULL && strchr_m(filter, *(s+1))!=NULL) {
return 0;
}
- fstat(localhandle, &localstat);
+ if (fstat(localhandle, &localstat) != 0) {
+ fprintf(stderr, "Can't fstat %s: %s\n", newpath, strerror(errno));
+ smbc_close(remotehandle);
+ close(localhandle);
+ return 0;
+ }
start_offset = localstat.st_size;