Re: [PATCH obexd 2/4] Add basic support for action commands on ftp driver
From: Hendrik Sattler <hidden>
Date: 2011-06-17 11:41:50
Hi, Zitat von Luiz Augusto von Dentz [off-list ref]:
On Fri, Jun 17, 2011 at 1:19 PM, Hendrik Sattler [off-list ref] wrote:quoted
Zitat von Luiz Augusto von Dentz [off-list ref]:quoted
+static char *ftp_build_filename(struct ftp_session *ftp, const char *destname) +{ + char *filename; + + /* DestName can either be relative or absolute (FTP style) */ + if (g_path_is_absolute(destname)) + filename = g_build_filename(destname, NULL); + else + filename = g_build_filename(ftp->folder, destname, NULL); + + /* Check if destination is inside root path */ + if (g_str_has_prefix(filename, ftp->folder)) + return filename; + + g_free(filename); + + return NULL; +}You should also catch stuff like the UNC path stuff and drive letter prefixes. No need to support all the sick stuff :-/If g_build_filename doesn't care I don't see why we should care.
Because strings like "\\..." and "C:\..." may return 0 with g_path_is_absolute(destname) and you then use a wrong directory that is not according to spec. HS