SilcSFTPHandle handle;
handle = silc_calloc(1, sizeof(*handle));
+ if (!handle)
+ return NULL;
handle->data = silc_calloc(data_len, sizeof(*handle->data));
+ if (!handle->data)
+ return NULL;
memcpy(handle->data, data, data_len);
handle->data_len = data_len;
hdata = (unsigned char *)va_arg(vp, unsigned char *);
hdata_len = (SilcUInt32)va_arg(vp, SilcUInt32);
handle = silc_sftp_handle_create(hdata, hdata_len);
+ if (!handle) {
+ if (req->handle)
+ (*req->handle)((SilcSFTP)sftp, status, NULL, req->context);
+ break;
+ }
if (req->handle)
(*req->handle)((SilcSFTP)sftp, status, handle, req->context);
return NULL;
sftp = silc_calloc(1, sizeof(*sftp));
+ if (!sftp)
+ return NULL;
sftp->send_packet = send_packet;
sftp->send_context = send_context;
sftp->version = callback;
SILC_LOG_DEBUG(("Open request"));
req = silc_calloc(1, sizeof(*req));
+ if (!req)
+ return;
req->id = client->id++;
req->type = SILC_SFTP_OPEN;
req->handle = callback;
silc_list_add(client->requests, req);
attrs_buf = silc_sftp_attr_encode(attrs);
+ if (attrs_buf)
+ return;
len = 4 + 4 + strlen(filename) + 4 + attrs_buf->len;
silc_sftp_send_packet(client, req->type, len,
SILC_LOG_DEBUG(("Close request"));
req = silc_calloc(1, sizeof(*req));
+ if (!req)
+ return;
req->id = client->id++;
req->type = SILC_SFTP_CLOSE;
req->status = callback;
SILC_LOG_DEBUG(("Read request"));
req = silc_calloc(1, sizeof(*req));
+ if (!req)
+ return;
req->id = client->id++;
req->type = SILC_SFTP_READ;
req->data = callback;
SILC_LOG_DEBUG(("Write request"));
req = silc_calloc(1, sizeof(*req));
+ if (!req)
+ return;
req->id = client->id++;
req->type = SILC_SFTP_WRITE;
req->status = callback;
SILC_LOG_DEBUG(("Remove request"));
req = silc_calloc(1, sizeof(*req));
+ if (!req)
+ return;
req->id = client->id++;
req->type = SILC_SFTP_REMOVE;
req->status = callback;
SILC_LOG_DEBUG(("Rename request"));
req = silc_calloc(1, sizeof(*req));
+ if (!req)
+ return;
req->id = client->id++;
req->type = SILC_SFTP_RENAME;
req->status = callback;
SILC_LOG_DEBUG(("Mkdir request"));
req = silc_calloc(1, sizeof(*req));
+ if (!req)
+ return;
req->id = client->id++;
req->type = SILC_SFTP_MKDIR;
req->status = callback;
silc_list_add(client->requests, req);
attrs_buf = silc_sftp_attr_encode(attrs);
+ if (attrs_buf)
+ return;
len = 4 + 4 + strlen(path) + attrs_buf->len;
silc_sftp_send_packet(client, req->type, len,
SILC_LOG_DEBUG(("Rmdir request"));
req = silc_calloc(1, sizeof(*req));
+ if (!req)
+ return;
req->id = client->id++;
req->type = SILC_SFTP_RMDIR;
req->status = callback;
SILC_LOG_DEBUG(("Opendir request"));
req = silc_calloc(1, sizeof(*req));
+ if (!req)
+ return;
req->id = client->id++;
req->type = SILC_SFTP_OPENDIR;
req->handle = callback;
SILC_LOG_DEBUG(("Readdir request"));
req = silc_calloc(1, sizeof(*req));
+ if (!req)
+ return;
req->id = client->id++;
req->type = SILC_SFTP_READDIR;
req->name = callback;
SILC_LOG_DEBUG(("Stat request"));
req = silc_calloc(1, sizeof(*req));
+ if (!req)
+ return;
req->id = client->id++;
req->type = SILC_SFTP_STAT;
req->attr = callback;
SILC_LOG_DEBUG(("Lstat request"));
req = silc_calloc(1, sizeof(*req));
+ if (!req)
+ return;
req->id = client->id++;
req->type = SILC_SFTP_LSTAT;
req->attr = callback;
SILC_LOG_DEBUG(("Fstat request"));
req = silc_calloc(1, sizeof(*req));
+ if (!req)
+ return;
req->id = client->id++;
req->type = SILC_SFTP_FSTAT;
req->attr = callback;
SILC_LOG_DEBUG(("Setstat request"));
req = silc_calloc(1, sizeof(*req));
+ if (!req)
+ return;
req->id = client->id++;
req->type = SILC_SFTP_SETSTAT;
req->status = callback;
silc_list_add(client->requests, req);
attrs_buf = silc_sftp_attr_encode(attrs);
+ if (attrs_buf)
+ return;
len = 4 + 4 + strlen(path) + attrs_buf->len;
silc_sftp_send_packet(client, req->type, len,
SILC_LOG_DEBUG(("Fsetstat request"));
req = silc_calloc(1, sizeof(*req));
+ if (!req)
+ return;
req->id = client->id++;
req->type = SILC_SFTP_FSETSTAT;
req->status = callback;
silc_sftp_handle_get(handle, &hdata, &hdata_len);
attrs_buf = silc_sftp_attr_encode(attrs);
+ if (attrs_buf)
+ return;
len = 4 + 4 + hdata_len + attrs_buf->len;
silc_sftp_send_packet(client, req->type, len,
SILC_LOG_DEBUG(("Readlink request"));
req = silc_calloc(1, sizeof(*req));
+ if (!req)
+ return;
req->id = client->id++;
req->type = SILC_SFTP_READLINK;
req->name = callback;
SILC_LOG_DEBUG(("Symlink request"));
req = silc_calloc(1, sizeof(*req));
+ if (!req)
+ return;
req->id = client->id++;
req->type = SILC_SFTP_SYMLINK;
req->status = callback;
SILC_LOG_DEBUG(("Realpath request"));
req = silc_calloc(1, sizeof(*req));
+ if (!req)
+ return;
req->id = client->id++;
req->type = SILC_SFTP_REALPATH;
req->name = callback;
SILC_LOG_DEBUG(("Extended request"));
req = silc_calloc(1, sizeof(*req));
+ if (!req)
+ return;
req->id = client->id++;
req->type = SILC_SFTP_WRITE;
req->extended = callback;