소스 검색

- fix double null termination of query string
- Patch provided from Iouri Kharon, yjh at styx dot cabel dot net


git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@3970 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt 17 년 전
부모
커밋
e2a96019f8
1개의 변경된 파일8개의 추가작업 그리고 8개의 파일을 삭제
  1. 8 8
      lib/srdb1/db_query.c

+ 8 - 8
lib/srdb1/db_query.c

@@ -168,9 +168,9 @@ int db_do_insert(const db_con_t* _h, const db_key_t* _k, const db_val_t* _v,
 	if (ret < 0) return -1;
 	off += ret;
 
-	if (off + 2 >= SQL_BUF_LEN) goto error;
+	if (off + 2 > SQL_BUF_LEN) goto error;
 	sql_buf[off++] = ')';
-	sql_buf[off + 1] = '\0';
+	sql_buf[off] = '\0';
 	sql_str.s = sql_buf;
 	sql_str.len = off;
 
@@ -212,8 +212,8 @@ int db_do_delete(const db_con_t* _h, const db_key_t* _k, const db_op_t* _o,
 		if (ret < 0) return -1;
 		off += ret;
 	}
-	if (off + 1 >= SQL_BUF_LEN) goto error;
-	sql_buf[off + 1] = '\0';
+	if (off + 1 > SQL_BUF_LEN) goto error;
+	sql_buf[off] = '\0';
 	sql_str.s = sql_buf;
 	sql_str.len = off;
 
@@ -258,8 +258,8 @@ int db_do_update(const db_con_t* _h, const db_key_t* _k, const db_op_t* _o,
 		if (ret < 0) return -1;
 		off += ret;
 	}
-	if (off + 1 >= SQL_BUF_LEN) goto error;
-	sql_buf[off + 1] = '\0';
+	if (off + 1 > SQL_BUF_LEN) goto error;
+	sql_buf[off] = '\0';
 	sql_str.s = sql_buf;
 	sql_str.len = off;
 
@@ -303,9 +303,9 @@ int db_do_replace(const db_con_t* _h, const db_key_t* _k, const db_val_t* _v,
 	if (ret < 0) return -1;
 	off += ret;
 
-	if (off + 2 >= SQL_BUF_LEN) goto error;
+	if (off + 2 > SQL_BUF_LEN) goto error;
 	sql_buf[off++] = ')';
-	sql_buf[off + 1] = '\0';
+	sql_buf[off] = '\0';
 	sql_str.s = sql_buf;
 	sql_str.len = off;