]> arthur.barton.de Git - netatalk.git/commitdiff
CNID/mysql: fix volume table name generation from UUID, bug #566
authorRalph Boehme <rb@sernet.de>
Wed, 19 Nov 2014 15:28:51 +0000 (16:28 +0100)
committerRalph Boehme <slow@samba.org>
Fri, 28 Nov 2014 12:05:33 +0000 (13:05 +0100)
Signed-off-by: Ralph Boehme <rb@sernet.de>
NEWS
libatalk/cnid/mysql/cnid_mysql.c

diff --git a/NEWS b/NEWS
index 999468c84a40a59578edab784dc26c6de6e14d6c..30fe9bd58fe312d0bf9fba83dac848f91e6f8647 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ Changes in 3.1.7
 * FIX: afpd: ACL related error messages, now logged with loglevel
        debug instead of error
 * FIX: cnid_metad: fix tsockfd_create() return value on error
+* FIX: CNID/MySQL: volume table name generation, bug #566.
 
 Changes in 3.1.6
 ================
index aa04bf81f259127585974ac9f2764e3a000a63e0..063d79f0c9a63c42b305e3ed9c3ba86641b51948 100644 (file)
@@ -815,18 +815,19 @@ static struct _cnid_db *cnid_mysql_new(struct vol *vol)
     return cdb;
 }
 
-static const char *printuuid(const unsigned char *uuid) {
-    static char uuidstring[64];
+/* Return allocated UUID string with dashes stripped */
+static char *uuid_strip_dashes(const char *uuid) {
+    static char stripped[33];
     int i = 0;
-    unsigned char c;
 
-    while ((c = *uuid)) {
+    while (*uuid && i < 32) {
+        if (*uuid != '-') {
+            stripped[i++] = *uuid;
+        }
         uuid++;
-        sprintf(uuidstring + i, "%02X", c);
-        i += 2;
     }
-    uuidstring[i] = 0;
-    return uuidstring;
+    stripped[i] = 0;
+    return strdup(stripped);
 }
 
 /* ---------------------- */
@@ -843,7 +844,7 @@ struct _cnid_db *cnid_mysql_open(struct cnid_open_args *args)
     EC_NULL( db = (CNID_mysql_private *)calloc(1, sizeof(CNID_mysql_private)) );
     cdb->cnid_db_private = db;
 
-    db->cnid_mysql_voluuid_str = strdup(printuuid(vol->v_uuid));
+    EC_NULL( db->cnid_mysql_voluuid_str = uuid_strip_dashes(vol->v_uuid) );
 
     /* Initialize and connect to MySQL server */
     EC_NULL( db->cnid_mysql_con = mysql_init(NULL) );