Zeev:
  I just finished coding up a patch to sybase-ct to add charset
support. I want to put it through a little more testing before I apply
it, but in the process, I found what appears to be a bug in the db
extension, and you seemed like the right person to talk to.

  It all comes from "hashed_details_length". If they specify a charset,
then hashed_details_length will be one byte too short...there is no
space allocated for the _ seperator in the hashed_details.

  So I followed what seemed to be the conventional wisdom, and added one
byte to all cases, and added an extra _ at the end of cases 1-3.

  Is this the correct way to do this? Was this even a bug, or are we
safe anyways?

  I attached the patch so you could take a look at it.
Index: ext/sybase/php_sybase_db.c
===================================================================
RCS file: /repository/php4/ext/sybase/php_sybase_db.c,v
retrieving revision 1.16
diff -u -r1.16 php_sybase_db.c
--- ext/sybase/php_sybase_db.c  12 Jun 2001 05:28:40 -0000      1.16
+++ ext/sybase/php_sybase_db.c  26 Jun 2001 12:39:08 -0000
@@ -282,9 +282,9 @@
                                }
                                convert_to_string(yyhost);
                                host = yyhost->value.str.val;
-                               hashed_details_length = yyhost->value.str.len+6+3;
+                               hashed_details_length = yyhost->value.str.len+6+4;
                                hashed_details = (char *) 
emalloc(hashed_details_length+1);
-                               
sprintf(hashed_details,"sybase_%s__",yyhost->value.str.val);
+                               
+sprintf(hashed_details,"sybase_%s___",yyhost->value.str.val);
                        }
                        break;
                case 2: {
@@ -297,9 +297,9 @@
                                convert_to_string(yyuser);
                                host = yyhost->value.str.val;
                                user = yyuser->value.str.val;
-                               hashed_details_length = 
yyhost->value.str.len+yyuser->value.str.len+6+3;
+                               hashed_details_length = 
+yyhost->value.str.len+yyuser->value.str.len+6+4;
                                hashed_details = (char *) 
emalloc(hashed_details_length+1);
-                               
sprintf(hashed_details,"sybase_%s_%s_",yyhost->value.str.val,yyuser->value.str.val);
+                               
+sprintf(hashed_details,"sybase_%s_%s__",yyhost->value.str.val,yyuser->value.str.val);
                        }
                        break;
                case 3: {
@@ -314,9 +314,9 @@
                                host = yyhost->value.str.val;
                                user = yyuser->value.str.val;
                                passwd = yypasswd->value.str.val;
-                               hashed_details_length = 
yyhost->value.str.len+yyuser->value.str.len+yypasswd->value.str.len+6+3;
+                               hashed_details_length = 
+yyhost->value.str.len+yyuser->value.str.len+yypasswd->value.str.len+6+4;
                                hashed_details = (char *) 
emalloc(hashed_details_length+1);
-                               
sprintf(hashed_details,"sybase_%s_%s_%s",yyhost->value.str.val,yyuser->value.str.val,yypasswd->value.str.val);
 /* SAFE */
+                               
+sprintf(hashed_details,"sybase_%s_%s_%s_",yyhost->value.str.val,yyuser->value.str.val,yypasswd->value.str.val);
+ /* SAFE */
                        }
                        break;
                case 4: {
@@ -333,7 +333,7 @@
                                user = yyuser->value.str.val;
                                passwd = yypasswd->value.str.val;
                                charset = yycharset->value.str.val;
-                               hashed_details_length = 
yyhost->value.str.len+yyuser->value.str.len+yypasswd->value.str.len+yycharset->value.str.len+6+3;

+                               hashed_details_length = 
+yyhost->value.str.len+yyuser->value.str.len+yypasswd->value.str.len+yycharset->value.str.len+6+4;
+
                                hashed_details = (char *) 
emalloc(hashed_details_length+1);
                                
sprintf(hashed_details,"sybase_%s_%s_%s_%s",yyhost->value.str.val,yyuser->value.str.val,yypasswd->value.str.val,yycharset->value.str.val);
 /* SAFE */
                        }
-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to