@@ -2076,9 +2076,9 @@ bool odbc_sqlconnect(zval *zv, char *db, char *uid, char *pwd, int cur_opt, bool
20762076
20772077 /* Force UID and PWD to be set in the DSN */
20782078 if (use_uid_arg || use_pwd_arg ) {
2079- db_end -- ;
2080- if (( unsigned char ) * ( db_end ) == ';' ) {
2081- * db_end = '\0' ;
2079+ size_t base_len = db_len ;
2080+ if (base_len > 0 && db [ base_len - 1 ] == ';' ) {
2081+ base_len -- ;
20822082 }
20832083
20842084 char * uid_quoted = NULL , * pwd_quoted = NULL ;
@@ -2094,7 +2094,7 @@ bool odbc_sqlconnect(zval *zv, char *db, char *uid, char *pwd, int cur_opt, bool
20942094 }
20952095
20962096 if (!use_pwd_arg ) {
2097- spprintf (& ldb , 0 , "%s;UID=%s;" , db , uid_quoted );
2097+ spprintf (& ldb , 0 , "%.* s;UID=%s;" , ( int ) base_len , db , uid_quoted );
20982098 }
20992099 }
21002100
@@ -2109,12 +2109,12 @@ bool odbc_sqlconnect(zval *zv, char *db, char *uid, char *pwd, int cur_opt, bool
21092109 }
21102110
21112111 if (!use_uid_arg ) {
2112- spprintf (& ldb , 0 , "%s;PWD=%s;" , db , pwd_quoted );
2112+ spprintf (& ldb , 0 , "%.* s;PWD=%s;" , ( int ) base_len , db , pwd_quoted );
21132113 }
21142114 }
21152115
21162116 if (use_uid_arg && use_pwd_arg ) {
2117- spprintf (& ldb , 0 , "%s;UID=%s;PWD=%s;" , db , uid_quoted , pwd_quoted );
2117+ spprintf (& ldb , 0 , "%.* s;UID=%s;PWD=%s;" , ( int ) base_len , db , uid_quoted , pwd_quoted );
21182118 }
21192119
21202120 if (uid_quoted && should_quote_uid ) {
0 commit comments