@@ -1952,9 +1952,9 @@ bool odbc_sqlconnect(zval *zv, char *db, char *uid, char *pwd, int cur_opt, bool
19521952
19531953 /* Force UID and PWD to be set in the DSN */
19541954 if (use_uid_arg || use_pwd_arg ) {
1955- db_end -- ;
1956- if (( unsigned char ) * ( db_end ) == ';' ) {
1957- * db_end = '\0' ;
1955+ size_t base_len = db_len ;
1956+ if (base_len > 0 && db [ base_len - 1 ] == ';' ) {
1957+ base_len -- ;
19581958 }
19591959
19601960 char * uid_quoted = NULL , * pwd_quoted = NULL ;
@@ -1970,7 +1970,7 @@ bool odbc_sqlconnect(zval *zv, char *db, char *uid, char *pwd, int cur_opt, bool
19701970 }
19711971
19721972 if (!use_pwd_arg ) {
1973- spprintf (& ldb , 0 , "%s;UID=%s;" , db , uid_quoted );
1973+ spprintf (& ldb , 0 , "%.* s;UID=%s;" , ( int ) base_len , db , uid_quoted );
19741974 }
19751975 }
19761976
@@ -1985,12 +1985,12 @@ bool odbc_sqlconnect(zval *zv, char *db, char *uid, char *pwd, int cur_opt, bool
19851985 }
19861986
19871987 if (!use_uid_arg ) {
1988- spprintf (& ldb , 0 , "%s;PWD=%s;" , db , pwd_quoted );
1988+ spprintf (& ldb , 0 , "%.* s;PWD=%s;" , ( int ) base_len , db , pwd_quoted );
19891989 }
19901990 }
19911991
19921992 if (use_uid_arg && use_pwd_arg ) {
1993- spprintf (& ldb , 0 , "%s;UID=%s;PWD=%s;" , db , uid_quoted , pwd_quoted );
1993+ spprintf (& ldb , 0 , "%.* s;UID=%s;PWD=%s;" , ( int ) base_len , db , uid_quoted , pwd_quoted );
19941994 }
19951995
19961996 if (uid_quoted && should_quote_uid ) {
0 commit comments