[Groonga-commit] groonga/groonga at 1ca380c [master] windows: use strncpy_s() on Windows

Zurück zum Archiv-Index

Kouhei Sutou null+****@clear*****
Wed Apr 15 23:58:51 JST 2015


Kouhei Sutou	2015-04-15 23:58:51 +0900 (Wed, 15 Apr 2015)

  New Revision: 1ca380c7892520fdb0d15c7e6371e1b8986eefd8
  https://github.com/groonga/groonga/commit/1ca380c7892520fdb0d15c7e6371e1b8986eefd8

  Message:
    windows: use strncpy_s() on Windows

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

  Modified: include/groonga/portability.h (+8 -0)
===================================================================
--- include/groonga/portability.h    2015-04-15 23:54:48 +0900 (cdd85c8)
+++ include/groonga/portability.h    2015-04-15 23:58:51 +0900 (d501973)
@@ -91,4 +91,12 @@
   strncat((dest), (src), (n))
 #endif /* WIN32 */
 
+#ifdef WIN32
+# define grn_strncpy(dest, dest_size, src, n)   \
+  strncpy_s((dest), (dest_size), (src), (n))
+#else /* WIN32 */
+# define grn_strncpy(dest, dest_size, src, n)   \
+  strncpy((dest), (src), (n))
+#endif /* WIN32 */
+
 #endif /* GROONGA_PORTABILITY_H */

  Modified: lib/db.c (+4 -1)
===================================================================
--- lib/db.c    2015-04-15 23:54:48 +0900 (66df967)
+++ lib/db.c    2015-04-15 23:58:51 +0900 (2be3da6)
@@ -7505,7 +7505,10 @@ grn_obj_set_info_source_validate_report_error(grn_ctx *ctx,
                                          GRN_TABLE_MAX_KEY_SIZE);
     grn_obj_unlink(ctx, source_type);
   } else {
-    strncpy(source_type_name, "(nil)", GRN_TABLE_MAX_KEY_SIZE);
+    grn_strncpy(source_type_name,
+                GRN_TABLE_MAX_KEY_SIZE,
+                "(nil)",
+                GRN_TABLE_MAX_KEY_SIZE);
     source_type_name_size = strlen(source_type_name);
   }
   ERR(GRN_INVALID_ARGUMENT,

  Modified: lib/io.c (+2 -2)
===================================================================
--- lib/io.c    2015-04-15 23:54:48 +0900 (324d30e)
+++ lib/io.c    2015-04-15 23:58:51 +0900 (c81b331)
@@ -301,7 +301,7 @@ grn_io_create(grn_ctx *ctx, const char *path, uint32_t header_size, uint32_t seg
         if ((io = GRN_GMALLOCN(grn_io, 1))) {
           grn_io_mapinfo *maps = NULL;
           if ((maps = GRN_GCALLOC(sizeof(grn_io_mapinfo) * max_segment))) {
-            strncpy(io->path, path, PATH_MAX);
+            grn_strncpy(io->path, PATH_MAX, path, PATH_MAX);
             io->header = header;
             io->user_header = (((byte *) header) + IO_HEADER_SIZE);
             io->maps = maps;
@@ -553,7 +553,7 @@ grn_io_open(grn_ctx *ctx, const char *path, grn_io_mode mode)
       if ((io = GRN_GMALLOC(sizeof(grn_io)))) {
         grn_io_mapinfo *maps = NULL;
         if ((maps = GRN_GCALLOC(sizeof(grn_io_mapinfo) * max_segment))) {
-          strncpy(io->path, path, PATH_MAX);
+          grn_strncpy(io->path, PATH_MAX, path, PATH_MAX);
           io->header = header;
           io->user_header = (((byte *) header) + IO_HEADER_SIZE);
           {
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Zurück zum Archiv-Index