@@ -757,7 +757,7 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg)
757
757
sdvalout= NULL ;
758
758
xmod= MODE_ANY;
759
759
istable= false ;
760
- * partname= 0 ;
760
+ memset ( partname, 0 , sizeof (partname)) ;
761
761
bzero ((char *) &xinfo, sizeof (XINFO));
762
762
valid_info= false ;
763
763
valid_query_id= 0 ;
@@ -1150,7 +1150,7 @@ char *ha_connect::GetRealString(const char *s)
1150
1150
{
1151
1151
char *sv;
1152
1152
1153
- if (IsPartitioned () && s) {
1153
+ if (IsPartitioned () && s && partname && *partname ) {
1154
1154
sv= (char *)PlugSubAlloc (xp->g , NULL , 0 );
1155
1155
sprintf (sv, s, partname);
1156
1156
PlugSubAlloc (xp->g , NULL , strlen (sv) + 1 );
@@ -1173,7 +1173,9 @@ char *ha_connect::GetStringOption(char *opname, char *sdef)
1173
1173
: table->s ->connect_string ;
1174
1174
1175
1175
if (cnc.length )
1176
- opval= GetRealString (strz (xp->g , cnc));
1176
+ opval= strz (xp->g , cnc);
1177
+ else
1178
+ opval= GetListOption (xp->g , opname, options->oplist );
1177
1179
1178
1180
} else if (!stricmp (opname, " Query_String" ))
1179
1181
opval= thd_query_string (table->in_use )->str ;
@@ -3121,13 +3123,14 @@ int ha_connect::open(const char *name, int mode, uint test_if_locked)
3121
3123
#if defined(WITH_PARTITION_STORAGE_ENGINE)
3122
3124
if (table->part_info ) {
3123
3125
if (GetStringOption (" Filename" ) || GetStringOption (" Tabname" )
3124
- || GetStringOption (" Connect" )) {
3125
- strcpy (partname, decode (g, strrchr (name, ' #' ) + 1 ));
3126
+ || GetStringOption (" Connect" )) {
3127
+ strncpy (partname, decode (g, strrchr (name, ' #' ) + 1 ), sizeof (partname) - 1 );
3126
3128
// strcpy(partname, table->part_info->curr_part_elem->partition_name);
3127
- part_id= &table->part_info ->full_part_field_set ;
3129
+ // part_id= &table->part_info->full_part_field_set;
3128
3130
} else // Inward table
3129
- strcpy (partname, strrchr (name, slash) + 1 );
3130
- part_id= &table->part_info ->full_part_field_set ; // Temporary
3131
+ strncpy (partname, strrchr (name, slash) + 1 , sizeof (partname) - 1 );
3132
+
3133
+ part_id= &table->part_info ->full_part_field_set ; // Temporary
3131
3134
} // endif part_info
3132
3135
#endif // WITH_PARTITION_STORAGE_ENGINE
3133
3136
} else
@@ -6142,7 +6145,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
6142
6145
6143
6146
strcpy (dbpath, name);
6144
6147
p= strrchr (dbpath, slash);
6145
- strcpy (partname, ++p);
6148
+ strncpy (partname, ++p, sizeof (partname) - 1 );
6146
6149
strcat (strcat (strcpy (buf, p), " ." ), lwt);
6147
6150
*p= 0 ;
6148
6151
} else {
@@ -6193,7 +6196,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
6193
6196
6194
6197
#if defined(WITH_PARTITION_STORAGE_ENGINE)
6195
6198
if (part_info && !inward)
6196
- strcpy (partname, decode (g, strrchr (name, ' #' ) + 1 ));
6199
+ strncpy (partname, decode (g, strrchr (name, ' #' ) + 1 ), sizeof (partname) - 1 );
6197
6200
// strcpy(partname, part_info->curr_part_elem->partition_name);
6198
6201
#endif // WITH_PARTITION_STORAGE_ENGINE
6199
6202
@@ -6234,8 +6237,9 @@ int ha_connect::create(const char *name, TABLE *table_arg,
6234
6237
6235
6238
#if defined(WITH_PARTITION_STORAGE_ENGINE)
6236
6239
if (part_info)
6237
- strcpy (partname,
6238
- decode (g, strrchr (name, (inward ? slash : ' #' )) + 1 ));
6240
+ strncpy (partname,
6241
+ decode (g, strrchr (name, (inward ? slash : ' #' )) + 1 ),
6242
+ sizeof (partname) - 1 );
6239
6243
#endif // WITH_PARTITION_STORAGE_ENGINE
6240
6244
6241
6245
if ((rc= optimize (table->in_use , NULL ))) {
0 commit comments