From 70bc46acf8279912f677580c21d9a364dedf9c25 Mon Sep 17 00:00:00 2001 From: Vinicius Costa Gomes Date: Mon, 24 May 2010 14:59:13 -0300 Subject: [PATCH] obexd: Fix FTP GET name handling The FTP service was only using the current folder name to build the target filename for GET requests. And we must reject requests without name and type headers: "Either the Type header or the Name header must be included in the GET request when it is sent to the server." -- GOEP --- obexd/plugins/ftp.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/obexd/plugins/ftp.c b/obexd/plugins/ftp.c index 945cfca20..c2dac9602 100644 --- a/obexd/plugins/ftp.c +++ b/obexd/plugins/ftp.c @@ -161,17 +161,25 @@ static int get_by_type(struct ftp_session *ftp, const char *type) { struct obex_session *os = ftp->os; const char *capability = obex_get_capability_path(os); + const char *name = obex_get_name(os); + char *path; + int err; - if (type == NULL) - return obex_get_stream_start(os, ftp->folder); + if (type == NULL && name == NULL) + return -EBADR; - if (g_str_equal(type, CAP_TYPE)) + if (g_strcmp0(type, CAP_TYPE) == 0) return obex_get_stream_start(os, capability); - if (g_str_equal(type, LST_TYPE)) + if (g_strcmp0(type, LST_TYPE) == 0) return obex_get_stream_start(os, ftp->folder); - return -ENOENT; + path = g_build_filename(ftp->folder, name, NULL); + err = obex_get_stream_start(os, path); + + g_free(path); + + return err; } static void *ftp_connect(struct obex_session *os, int *err) -- 2.47.3