[Groonga-commit] groonga/groonga [master] fix writing out of bounds

Back to archive index

null+****@clear***** null+****@clear*****
2010年 6月 25日 (金) 14:26:26 JST


Nobuyoshi Nakada	2010-06-25 05:26:26 +0000 (Fri, 25 Jun 2010)

  New Revision: 7a849d439454ace9533d734e51448af882fd0e37

  Log:
    fix writing out of bounds

  Modified files:
    src/groonga.c

  Modified: src/groonga.c (+4 -4)
===================================================================
--- src/groonga.c    2010-06-25 06:25:59 +0000 (e4f17e3)
+++ src/groonga.c    2010-06-25 05:26:26 +0000 (56cfd68)
@@ -1805,18 +1805,18 @@ main(int argc, char **argv)
   grn_set_term_handler();
   if (listen_addressstr) {
     size_t listen_addresslen = strlen(listen_addressstr);
-    if (listen_addresslen > HOST_NAME_MAX) {
+    if (listen_addresslen > HOST_NAME_MAX - 1) {
       memcpy(listen_address, listen_addressstr, HOST_NAME_MAX - 1);
-      listen_address[HOST_NAME_MAX] = '\0';
+      listen_address[HOST_NAME_MAX - 1] = '\0';
     } else {
       strcpy(listen_address, listen_addressstr);
     }
   }
   if (hostnamestr) {
     size_t hostnamelen = strlen(hostnamestr);
-    if (hostnamelen > HOST_NAME_MAX) {
+    if (hostnamelen > HOST_NAME_MAX - 1) {
       memcpy(hostname, hostnamestr, HOST_NAME_MAX - 1);
-      hostname[HOST_NAME_MAX] = '\0';
+      hostname[HOST_NAME_MAX - 1] = '\0';
     } else {
       strcpy(hostname, hostnamestr);
     }




Groonga-commit メーリングリストの案内
Back to archive index