summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2011-02-21 10:58:15 +0000
committerSebastian Huber <sebastian.huber@embedded-brains.de>2011-02-21 10:58:15 +0000
commit00db336a00adfde2b05f0d039e379f6e45fdd0ec (patch)
tree87cc436b94708712fcdc4f9f2fc5a5870c23ecec /cpukit
parentAdd -mcpu=8540/-mfloat-gprs=double multilib. (diff)
downloadrtems-00db336a00adfde2b05f0d039e379f6e45fdd0ec.tar.bz2
2011-02-21 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libnetworking/lib/ftpfs.c: Workaround for some firewalls.
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/ChangeLog4
-rw-r--r--cpukit/libnetworking/lib/ftpfs.c57
2 files changed, 31 insertions, 30 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog
index 214320e93a..e20dbd43c4 100644
--- a/cpukit/ChangeLog
+++ b/cpukit/ChangeLog
@@ -1,3 +1,7 @@
+2011-02-21 Sebastian Huber <sebastian.huber@embedded-brains.de>
+
+ * libnetworking/lib/ftpfs.c: Workaround for some firewalls.
+
2011-02-18 Joel Sherrill <joel.sherrill@oarcorp.com>
* sapi/include/confdefs.h, score/Makefile.am,
diff --git a/cpukit/libnetworking/lib/ftpfs.c b/cpukit/libnetworking/lib/ftpfs.c
index 00467e5e9b..0f2183409c 100644
--- a/cpukit/libnetworking/lib/ftpfs.c
+++ b/cpukit/libnetworking/lib/ftpfs.c
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2009, 2010
+ * Copyright (c) 2009, 2010, 2011
* embedded brains GmbH
* Obere Lagerstr. 30
* D-82178 Puchheim
@@ -347,40 +347,37 @@ static rtems_ftpfs_reply rtems_ftpfs_send_command_with_parser(
bool verbose
)
{
- const char *const eol = "\r\n";
- int rv = 0;
-
- /* Send command */
- rv = send(socket, cmd, strlen(cmd), 0);
- if (rv < 0) {
- return RTEMS_FTPFS_REPLY_ERROR;
- }
- if (verbose) {
- write(STDERR_FILENO, cmd, strlen(cmd));
- }
+ rtems_ftpfs_reply reply = RTEMS_FTPFS_REPLY_ERROR;
+ size_t cmd_len = strlen(cmd);
+ size_t arg_len = arg != NULL ? strlen(arg) : 0;
+ size_t len = cmd_len + arg_len + 2;
+ char *buf = malloc(len);
+
+ if (buf != NULL) {
+ ssize_t n = 0;
+ char *buf_arg = buf + cmd_len;
+ char *buf_eol = buf_arg + arg_len;
+
+ memcpy(buf, cmd, cmd_len);
+ memcpy(buf_arg, arg, arg_len);
+ buf_eol [0] = '\r';
+ buf_eol [1] = '\n';
+
+ /* Send */
+ n = send(socket, buf, len, 0);
+ if (n == (ssize_t) len) {
+ if (verbose) {
+ write(STDERR_FILENO, buf, len);
+ }
- /* Send command argument if necessary */
- if (arg != NULL) {
- rv = send(socket, arg, strlen(arg), 0);
- if (rv < 0) {
- return RTEMS_FTPFS_REPLY_ERROR;
- }
- if (verbose) {
- write(STDERR_FILENO, arg, strlen(arg));
+ /* Reply */
+ reply = rtems_ftpfs_get_reply(socket, parser, parser_arg, verbose);
}
- }
- /* Send end of line */
- rv = send(socket, eol, 2, 0);
- if (rv < 0) {
- return RTEMS_FTPFS_REPLY_ERROR;
- }
- if (verbose) {
- write(STDERR_FILENO, &eol [1], 1);
+ free(buf);
}
- /* Return reply */
- return rtems_ftpfs_get_reply(socket, parser, parser_arg, verbose);
+ return reply;
}
static rtems_ftpfs_reply rtems_ftpfs_send_command(