Navigation Menu

Skip to content

Commit

Permalink
windows: use strncat_s() on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Apr 15, 2015
1 parent fd20a88 commit 3283f43
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
8 changes: 8 additions & 0 deletions include/groonga/portability.h
Expand Up @@ -83,4 +83,12 @@
# define grn_unlink(filename) unlink((filename))
#endif /* WIN32 */

#ifdef WIN32
# define grn_strncat(dest, dest_size, src, n) \
strncat_s((dest), (dest_size), (src), (n))
#else /* WIN32 */
# define grn_strncat(dest, dest_size, src, n) \
strncat((dest), (src), (n))
#endif /* WIN32 */

#endif /* GROONGA_PORTABILITY_H */
6 changes: 4 additions & 2 deletions lib/db.c
Expand Up @@ -7489,8 +7489,10 @@ grn_obj_set_info_source_validate_report_error(grn_ctx *ctx,
source_name, GRN_TABLE_MAX_KEY_SIZE);
if (GRN_OBJ_TABLEP(source)) {
source_name[source_name_size] = '\0';
strncat(source_name, "._key",
GRN_TABLE_MAX_KEY_SIZE - source_name_size - 1);
grn_strncat(source_name,
GRN_TABLE_MAX_KEY_SIZE,
"._key",
GRN_TABLE_MAX_KEY_SIZE - source_name_size - 1);
source_name_size = strlen(source_name);
}
table_domain_name_size = grn_obj_name(ctx, table_domain,
Expand Down
2 changes: 1 addition & 1 deletion lib/plugin.c
Expand Up @@ -623,7 +623,7 @@ grn_plugin_find_path_libs_so(grn_ctx *ctx, const char *path, size_t path_len)
}

libs_so_path[0] = '\0';
strncat(libs_so_path, path, base_name - path);
grn_strncat(libs_so_path, PATH_MAX, path, base_name - path);
strcat(libs_so_path, libs_path);
strcat(libs_so_path, base_name);
strcat(libs_so_path, so_suffix);
Expand Down
2 changes: 1 addition & 1 deletion lib/proc.c
Expand Up @@ -2728,7 +2728,7 @@ dump_plugins(grn_ctx *ctx, grn_obj *outbuf)
}
start_libs = strstr(relative_path, libs_path);
if (start_libs) {
strncat(name, relative_path, start_libs - relative_path);
grn_strncat(name, PATH_MAX, relative_path, start_libs - relative_path);
strcat(name, "/");
strcat(name, start_libs + strlen(libs_path));
} else {
Expand Down

0 comments on commit 3283f43

Please sign in to comment.