mirror of
https://github.com/mdbtools/mdbtools.git
synced 2026-03-10 00:20:54 +08:00
Fix misuse of "%*s" in sprintf strings
%*s takes the output length, not the input length. The intended
specifier was %.*s in several places. Bug(s) introduced in
2bb31f05ee
This commit is contained in:
@@ -191,7 +191,7 @@ mdb_ascii2unicode(MdbHandle *mdb, const char *src, size_t slen, char *dest, size
|
|||||||
#else
|
#else
|
||||||
if (IS_JET3(mdb)) {
|
if (IS_JET3(mdb)) {
|
||||||
int count;
|
int count;
|
||||||
snprintf(out_ptr, len_out, "%*s%n", (int)len_in, in_ptr, &count);
|
snprintf(out_ptr, len_out, "%.*s%n", (int)len_in, in_ptr, &count);
|
||||||
dlen = count;
|
dlen = count;
|
||||||
} else {
|
} else {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ mdb_read_props(MdbHandle *mdb, GPtrArray *names, gchar *kkd, int len)
|
|||||||
dsize = mdb_get_int16(kkd, pos + 6);
|
dsize = mdb_get_int16(kkd, pos + 6);
|
||||||
if (dsize < 0 || pos + 8 + dsize > len)
|
if (dsize < 0 || pos + 8 + dsize > len)
|
||||||
break;
|
break;
|
||||||
value = g_strdup_printf("%*s", dsize, &kkd[pos+8]);
|
value = g_strdup_printf("%.*s", dsize, &kkd[pos+8]);
|
||||||
name = g_ptr_array_index(names,elem);
|
name = g_ptr_array_index(names,elem);
|
||||||
if (mdb_get_option(MDB_DEBUG_PROPS)) {
|
if (mdb_get_option(MDB_DEBUG_PROPS)) {
|
||||||
fprintf(stderr, "%02d ",i++);
|
fprintf(stderr, "%02d ",i++);
|
||||||
|
|||||||
@@ -1225,7 +1225,7 @@ SQLRETURN SQL_API SQLPrepare(
|
|||||||
|
|
||||||
TRACE("SQLPrepare");
|
TRACE("SQLPrepare");
|
||||||
|
|
||||||
snprintf(stmt->query, sizeof(stmt->query), "%*s", sqllen, (char*)szSqlStr);
|
snprintf(stmt->query, sizeof(stmt->query), "%.*s", sqllen, (char*)szSqlStr);
|
||||||
|
|
||||||
return SQL_SUCCESS;
|
return SQL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -486,7 +486,7 @@ mdb_sql_add_sarg(MdbSQL *sql, char *col_name, int op, char *constant)
|
|||||||
** column definition can be checked for validity
|
** column definition can be checked for validity
|
||||||
*/
|
*/
|
||||||
if (constant[0]=='\'') {
|
if (constant[0]=='\'') {
|
||||||
snprintf(node->value.s, sizeof(node->value.s), "%*s", (int)strlen(constant) - 2, &constant[1]);
|
snprintf(node->value.s, sizeof(node->value.s), "%.*s", (int)strlen(constant) - 2, &constant[1]);
|
||||||
node->val_type = MDB_TEXT;
|
node->val_type = MDB_TEXT;
|
||||||
} else if ((p=strchr(constant, '.'))) {
|
} else if ((p=strchr(constant, '.'))) {
|
||||||
*p=localeconv()->decimal_point[0];
|
*p=localeconv()->decimal_point[0];
|
||||||
|
|||||||
Reference in New Issue
Block a user