svnno****@sourc*****
svnno****@sourc*****
Sat Mar 1 03:06:13 JST 2008
Revision: 3417 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=3417 Author: pal_gene Date: 2008-03-01 03:06:13 +0900 (Sat, 01 Mar 2008) Log Message: ----------- * src/utils/utils.c: Fix possibility trying allocate with 0xffffffff bytes. Modified Paths: -------------- kazehakase/trunk/ChangeLog kazehakase/trunk/src/utils/utils.c Modified: kazehakase/trunk/ChangeLog =================================================================== --- kazehakase/trunk/ChangeLog 2008-02-29 13:47:59 UTC (rev 3416) +++ kazehakase/trunk/ChangeLog 2008-02-29 18:06:13 UTC (rev 3417) @@ -1,3 +1,7 @@ +2008-03-01 Shunichi Fuji <palgl****@gmail*****> + * src/utils/utils.c: + Fix possibility trying allocate with 0xffffffff bytes. + 2008-02-29 Ryo SHIMIZU <furyo****@on-ai*****> * configure.ac: version 0.5.3 Modified: kazehakase/trunk/src/utils/utils.c =================================================================== --- kazehakase/trunk/src/utils/utils.c 2008-02-29 13:47:59 UTC (rev 3416) +++ kazehakase/trunk/src/utils/utils.c 2008-02-29 18:06:13 UTC (rev 3417) @@ -287,35 +287,32 @@ } +/** + * create uri string from local cache file (ex. /users/http/path.to/data to http://path.to/data) + * @param filename filename to create uri for local file path + * @return new allocated uri string, that should be g_free + */ gchar * create_uri_from_filename (const gchar *filename) { - gchar *uri; - gchar *pos; - gchar *scheme; - gchar *path; + gchar *uri, *pos, *scheme, *path; pos = strstr(filename, G_DIR_SEPARATOR_S); - if (!pos) return g_strdup(filename); scheme = g_strndup(filename, pos - filename); - - if (g_str_has_suffix(filename, G_DIR_SEPARATOR_S"_")) + if (g_str_has_suffix(pos + 1, G_DIR_SEPARATOR_S"_")) { path = g_strndup(pos + 1, strlen(pos) - 2); } else { - gchar *query_pos = g_strrstr(filename, "_"G_DIR_SEPARATOR_S); + gchar *query_pos = g_strrstr(pos + 1, "_"G_DIR_SEPARATOR_S); if (query_pos) { gchar *string = g_strndup(pos + 1, query_pos - pos - 1); - path = g_strconcat(string, - "?", - query_pos + 2, - NULL); + path = g_strconcat(string, "?", query_pos + 2, NULL); g_free(string); } else