[Groonga-commit] groonga/groonga at 3283f43 [master] windows: use strncat_s() on Windows

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Apr 15 23:54:48 JST 2015


Kouhei Sutou	2015-04-15 23:54:48 +0900 (Wed, 15 Apr 2015)

  New Revision: 3283f43bab72d64095be7958293b402facfa32d9
  https://github.com/groonga/groonga/commit/3283f43bab72d64095be7958293b402facfa32d9

  Message:
    windows: use strncat_s() on Windows

  Modified files:
    include/groonga/portability.h
    lib/db.c
    lib/plugin.c
    lib/proc.c

  Modified: include/groonga/portability.h (+8 -0)
===================================================================
--- include/groonga/portability.h    2015-04-15 23:45:32 +0900 (152371e)
+++ include/groonga/portability.h    2015-04-15 23:54:48 +0900 (cdd85c8)
@@ -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 */

  Modified: lib/db.c (+4 -2)
===================================================================
--- lib/db.c    2015-04-15 23:45:32 +0900 (268ac9b)
+++ lib/db.c    2015-04-15 23:54:48 +0900 (66df967)
@@ -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,

  Modified: lib/plugin.c (+1 -1)
===================================================================
--- lib/plugin.c    2015-04-15 23:45:32 +0900 (7212d68)
+++ lib/plugin.c    2015-04-15 23:54:48 +0900 (cc8c852)
@@ -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);

  Modified: lib/proc.c (+1 -1)
===================================================================
--- lib/proc.c    2015-04-15 23:45:32 +0900 (e923eff)
+++ lib/proc.c    2015-04-15 23:54:48 +0900 (d284d42)
@@ -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 {
-------------- next part --------------
HTML����������������������������...
下载 



More information about the Groonga-commit mailing list
Back to archive index