From: <da...@br...> - 2002-10-25 21:18:39
|
Update of /home/cvs/libdbi/drivers/mysql In directory backbeat:/tmp/cvs-serv18496/drivers/mysql Modified Files: dbd_mysql.c Log Message: updated mysql's binary null termination Index: dbd_mysql.c =================================================================== RCS file: /home/cvs/libdbi/drivers/mysql/dbd_mysql.c,v retrieving revision 1.57 retrieving revision 1.58 diff -u -d -r1.57 -r1.58 --- dbd_mysql.c 21 Oct 2002 06:47:16 -0000 1.57 +++ dbd_mysql.c 25 Oct 2002 21:18:33 -0000 1.58 @@ -416,8 +416,12 @@ break; case DBI_TYPE_BINARY: row->field_sizes[curfield] = (unsigned long long) strsizes[curfield]; - data->d_string = malloc(strsizes[curfield]+1); // XXX debatable for non-mysql, need to reread mailing list thread - memcpy(data->d_string, raw, strsizes[curfield]+1); // XXX + data->d_string = malloc(strsizes[curfield]+1); // one extra char for libdbi's null + memcpy(data->d_string, raw, strsizes[curfield]); + data->d_string[strsizes[curfield]] = '\0'; // manually null-terminate the data so C string casting still works + if (dbi_conn_get_option_numeric(result->conn, "mysql_include_trailing_null") == 1) { + row->field_sizes[curfield]++; // the extra null we added was actually part of the original data + } break; case DBI_TYPE_DATETIME: sizeattrib = _isolate_attrib(result->field_attribs[curfield], DBI_DATETIME_DATE, DBI_DATETIME_TIME); |