Changeset: b6fe520fc28f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b6fe520fc28f
Modified Files:
        
Branch: default
Log Message:

Merge with Aug2011 branch.


diffs (148 lines):

diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -399,7 +399,7 @@
        char *t;
        int rows = 0;           /* return number of output lines printed */
        size_t ulen;
-       int *cutafter = alloca(sizeof(int) * fields);
+       int *cutafter = malloc(sizeof(int) * fields);
 
        /* trim the text if needed */
        if (trim == 1) {
@@ -528,6 +528,8 @@
                first = 0;
                rows++;
        } while (more);
+
+       free(cutafter);
        return rows;
 }
 
@@ -966,8 +968,8 @@
        SQLseparator(len, fields, '-');
        if (mapi_get_name(hdl, 0)) {
                int i;
-               char **names = (char **) alloca(fields * sizeof(char *));
-               int *numeric = (int *) alloca(fields * sizeof(int));
+               char **names = (char **) malloc(fields * sizeof(char *));
+               int *numeric = (int *) malloc(fields * sizeof(int));
 
                for (i = 0; i < fields; i++) {
                        names[i] = mapi_get_name(hdl, i);
@@ -975,6 +977,8 @@
                }
                SQLrow(len, numeric, names, fields, 1, more);
                SQLseparator(len, fields, '=');
+               free(names);
+               free(numeric);
        }
 }
 
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -2559,18 +2559,20 @@
                         * sequence is used.
                         */
                        unsigned char md[20];   /* should be 
RIPEMD160_DIGEST_LENGTH */
-                       size_t n = strlen(mid->password) + strlen(chal);
-                       char *key = alloca(n + 1);
-                       key[0] = '\0';
+                       char *p;
+                       RIPEMD160_CTX c;
 
                        if (pversion == 9) {
-                               strcpy(key, mid->password + 1);
-                               n--;
+                               p = mid->password + 1;
                        } else {
-                               strcpy(key, mid->password);
+                               p = mid->password;
                        }
-                       strncat(key, chal, strlen(chal));
-                       RIPEMD160((unsigned char *) key, n, md);
+
+                       RIPEMD160_Init(&c);
+                       RIPEMD160_Update(&c, p, strlen(p));
+                       RIPEMD160_Update(&c, chal, strlen(chal));
+                       RIPEMD160_Final(md, &c);
+
                        hash = malloc(sizeof(char) * ( /*{RIPEMD160} */ 11 + 20 
* 2 + 1));
                        sprintf(hash, 
"{RIPEMD160}%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
                                "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
@@ -2588,18 +2590,20 @@
                         * sequence is used.
                         */
                        unsigned char md[20];   /* should be SHA_DIGEST_LENGTH 
*/
-                       size_t n = strlen(mid->password) + strlen(chal);
-                       char *key = alloca(n + 1);
-                       key[0] = '\0';
+                       char *p;
+                       SHA_CTX c;
 
                        if (pversion == 9) {
-                               strcpy(key, mid->password + 1);
-                               n--;
+                               p = mid->password + 1;
                        } else {
-                               strcpy(key, mid->password);
+                               p = mid->password;
                        }
-                       strncat(key, chal, strlen(chal));
-                       SHA1((unsigned char *) key, n, md);
+
+                       SHA1_Init(&c);
+                       SHA1_Update(&c, p, strlen(p));
+                       SHA1_Update(&c, chal, strlen(chal));
+                       SHA1_Final(md, &c);
+
                        hash = malloc(sizeof(char) * ( /*{SHA1} */ 6 + 20 * 2 + 
1));
                        sprintf(hash, 
"{SHA1}%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
                                "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
@@ -2617,18 +2621,20 @@
                         * sequence is used.
                         */
                        unsigned char md[16];   /* should be MD5_DIGEST_LENGTH 
*/
-                       size_t n = strlen(mid->password) + strlen(chal);
-                       char *key = alloca(n + 1);
-                       key[0] = '\0';
+                       char *p;
+                       MD5_CTX c;
 
                        if (pversion == 9) {
-                               strcpy(key, mid->password + 1);
-                               n--;
+                               p = mid->password + 1;
                        } else {
-                               strcpy(key, mid->password);
+                               p = mid->password;
                        }
-                       strncat(key, chal, strlen(chal));
-                       MD5((unsigned char *) key, n, md);
+
+                       MD5_Init(&c);
+                       MD5_Update(&c, p, strlen(p));
+                       MD5_Update(&c, chal, strlen(chal));
+                       MD5_Final(md, &c);
+
                        hash = malloc(sizeof(char) * ( /*{MD5} */ 5 + 16 * 2 + 
1));
                        sprintf(hash, "{MD5}%02x%02x%02x%02x%02x%02x%02x%02x"
                                "%02x%02x%02x%02x%02x%02x%02x%02x",
@@ -2875,12 +2881,11 @@
                                }
                                return mapi_start_talking(mid);
                        } else {
-                               q = alloca(sizeof(char) * (strlen(red) + 50));
-                               snprintf(q, strlen(red) + 50,
-                                        "error while parsing redirect: %s\n",
-                                        red);
+                               char re[BUFSIZ];
+                               snprintf(re, sizeof(re),
+                                               "error while parsing redirect: 
%s\n", red);
                                mapi_close_handle(hdl);
-                               mapi_setError(mid, q, "mapi_start_talking", 
MERROR);
+                               mapi_setError(mid, re, "mapi_start_talking", 
MERROR);
                                return mid->error;
                        }
                }
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to