Merge in a number of fixes for OpenBSD.
[awesomized/libmemcached] / clients / ms_conn.c
index 005879bdaaed7a994df109a7493fe82565a3fe0c..d7cd2de06c5b4c813e1789151e949431868b6875 100644 (file)
@@ -800,7 +800,7 @@ static int ms_network_connect(ms_conn_t *c,
 #ifdef AI_ADDRCONFIG
   hints.ai_flags= AI_PASSIVE | AI_ADDRCONFIG;
 #else
-+  hints.ai_flags= AI_PASSIVE;
+  hints.ai_flags= AI_PASSIVE;
 #endif /* AI_ADDRCONFIG */
   if (is_udp)
   {
@@ -2886,13 +2886,14 @@ static int ms_build_ascii_write_buf_set(ms_conn_t *c, ms_task_item_t *item)
   int write_len;
   char *buffer= c->wbuf;
 
-  write_len= sprintf(buffer,
-                     " %u %d %d\r\n",
-                     0,
-                     item->exp_time,
-                     item->value_size);
+  write_len= snprintf(buffer,
+                      c->wsize,
+                      " %u %d %d\r\n",
+                      0,
+                      item->exp_time,
+                      item->value_size);
 
-  if (write_len > c->wsize)
+  if (write_len > c->wsize || write_len < 0)
   {
     /* ought to be always enough. just fail for simplicity */
     fprintf(stderr, "output command line too long.\n");