null+****@clear*****
null+****@clear*****
2011年 11月 13日 (日) 16:07:05 JST
Kouhei Sutou 2011-11-13 07:07:05 +0000 (Sun, 13 Nov 2011)
New Revision: 9a97b2005c27a03e765ce318475362e0e4324836
Log:
[plugin] fix error message on too long plugin path.
Modified files:
lib/plugin.c
test/unit/core/test-plugin.c
Modified: lib/plugin.c (+11 -6)
===================================================================
--- lib/plugin.c 2011-11-13 05:11:26 +0000 (1ac8fb8)
+++ lib/plugin.c 2011-11-13 07:07:05 +0000 (2787908)
@@ -273,8 +273,8 @@ grn_plugin_register_by_path(grn_ctx *ctx, const char *path)
size_t path_len;
if ((path_len = strlen(path)) >= PATH_MAX) {
- ERR(GRN_FILENAME_TOO_LONG, "too long path");
- GRN_API_RETURN(ctx->rc);
+ ERR(GRN_FILENAME_TOO_LONG, "too long plugin path: <%s>", path);
+ goto exit;
}
plugin_file = fopen(path, "r");
if (plugin_file) {
@@ -282,8 +282,10 @@ grn_plugin_register_by_path(grn_ctx *ctx, const char *path)
id = grn_plugin_open(ctx, path);
} else {
if ((path_len += strlen(grn_plugin_get_suffix())) >= PATH_MAX) {
- ERR(GRN_FILENAME_TOO_LONG, "too long path");
- GRN_API_RETURN(ctx->rc);
+ ERR(GRN_FILENAME_TOO_LONG,
+ "too long plugin path: <%s%s>",
+ path, grn_plugin_get_suffix());
+ goto exit;
}
strcpy(complemented_path, path);
strcat(complemented_path, grn_plugin_get_suffix());
@@ -301,8 +303,10 @@ grn_plugin_register_by_path(grn_ctx *ctx, const char *path)
if (base_name) {
path_len = base_name - path + strlen("/.libs") + strlen(base_name);
if ((path_len += strlen(grn_plugin_get_suffix())) >= PATH_MAX) {
- ERR(GRN_FILENAME_TOO_LONG, "too long path");
- GRN_API_RETURN(ctx->rc);
+ ERR(GRN_FILENAME_TOO_LONG,
+ "too long plugin path: <%.*s/.libs%s%s>",
+ base_name - path, path, base_name, grn_plugin_get_suffix());
+ goto exit;
}
complemented_libs_path[0] = '\0';
strncat(complemented_libs_path, path, base_name - path);
@@ -337,6 +341,7 @@ grn_plugin_register_by_path(grn_ctx *ctx, const char *path)
} else {
ERR(GRN_INVALID_ARGUMENT, "invalid db assigned");
}
+exit :
GRN_API_RETURN(ctx->rc);
}
Modified: test/unit/core/test-plugin.c (+2 -3)
===================================================================
--- test/unit/core/test-plugin.c 2011-11-13 05:11:26 +0000 (e7da032)
+++ test/unit/core/test-plugin.c 2011-11-13 07:07:05 +0000 (d3ddfe8)
@@ -135,11 +135,10 @@ test_register_too_long_name(void)
full_path = cut_take_string(g_build_filename(plugins_dir,
long_name->str,
NULL));
- error_message_without_path =
- "cannot open shared object file: No such file or directory: <";
+ error_message_without_path = "too long plugin path: <";
grn_test_assert_send_command_error(
context,
- GRN_NO_SUCH_FILE_OR_DIRECTORY,
+ GRN_FILENAME_TOO_LONG,
cut_take_printf("%s%.*s",
error_message_without_path,
(int)(GRN_CTX_MSGSIZE -