Menu

#11 less string sizes

closed-fixed
None
5
2005-06-12
2002-11-21
No

hi guys,

this problem costs me 1 hour of work to get rid of it.
So, I'm using database and table and column names longer then 16
chars. but in your definition of a database name is 16 chars enough.
That's a serious bug.
But thats not enough, I changed for testing purposes all fields to a
max char size of 64, that means in the options.* struct I put 64+1 as
size.
but, pam_mysql segfaulted.
why ?
original
sql = (char *) malloc (110 + strlen(user) + strlen(options.where));

new one, but also wrong:
sql = (char *) malloc (196 + strlen(user) + strlen(options.where));

please change this.

I think it's better to use a concat solution then this here.

regards,

\sh

Discussion

  • James O'Kane

    James O'Kane - 2002-11-21

    Logged In: YES
    user_id=7767

    Someone pointed this out and I've fixed it in CVS, but have
    not released a new version yet. Could you test the newest
    version from CVS?

     
  • James O'Kane

    James O'Kane - 2002-11-21
    • assigned_to: nobody --> jo2y
    • status: open --> open-fixed
     
  • Stephan Hermann

    Stephan Hermann - 2002-11-22

    Logged In: YES
    user_id=289804

    hi,

    of course, you fixed the problem with the building of the select statement
    and the fixed size of it, but this is not the only problem.

    your structure of the database configuration is not good.
    you believe that a database name has max. 16 chars, but it could be more.
    So you need to increase the size of all fields from char[16] to e.g. char[128],
    or you find a solution to dynamically assign the strings from the
    configuration line.

    Why don't you use a tokenizer ? and after that, split up the tokens into
    <key>=<value> and copy it dynamically into the structure ?

    when I have time this friday, I'll try to send you a patch for it.

    regards

    \sh

     
  • James O'Kane

    James O'Kane - 2002-11-22

    Logged In: YES
    user_id=7767

    I didn't know what tokenizers were in 1999 when I wrote that
    part. :)
    If you have a patch already or almost finish go ahead and
    send it. But, my plan in the next two versions is to merge
    some of the code between this and the mysql-nss project, so
    they can use the same config file.

     
  • Alex Klayman

    Alex Klayman - 2004-01-06

    Logged In: YES
    user_id=763718

    Actually the MySQL 4.0.x that I am using limits host name
    and table name to 60 characters. Just look at
    mysql.tables_priv structure to see it. Database names
    however are limited to 64 characters, and user names to 16.

    mysql> describe mysql.tables_priv;
    +-------------+------------------+------+-----+---------+-------+
    | Field | Type | Null | Key | Default |
    Extra |
    +-------------+------------------+------+-----+---------+-------+
    | Host | char(60) binary | | PRI | |
    |
    | Db | char(64) binary | | PRI | |
    |
    | User | char(16) binary | | PRI | |
    |
    | Table_name | char(60) binary | | PRI | |
    |
    ...
    8 rows in set (0.00 sec)

     
  • Moriyoshi Koizumi

    Logged In: YES
    user_id=995831

    In the next 0.6 release all string variables are allocated dynamically and so
    no such problem like this should happen.

     
  • Moriyoshi Koizumi

    • status: open-fixed --> closed-fixed
     

Log in to post a comment.