Changeset 3465 for branches


Ignore:
Timestamp:
Sep 11, 2015, 10:55:49 AM (4 years ago)
Author:
bruno
Message:

-Improve memory management of netfs_user by duplicating systematically strings instead of optimizing by reusing content (should fix #766)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mondo/src/common/libmondo-cli.c

    r3413 r3465  
    153153    char *p = NULL;
    154154    char *q = NULL;
     155    char *q2 = NULL;
    155156
    156157    long itbs = 0L;
     
    440441        /* p points on to the string server:/path */
    441442        /* Store the 2 values */
    442         /*  using memmove instead of strcpy as per #584 */
    443         /* memmove(bkpinfo->netfs_mount, p, MAX_STR_LEN); */
    444         bkpinfo->netfs_mount = p;
     443        q2 = bkpinfo->netfs_mount;
     444        mr_asprintf(bkpinfo->netfs_mount, "%s", p);
     445        mr_free(q2);
    445446
    446447        /* test if we specified a user */
     
    448449        if (p != NULL) {
    449450            /* User found. Store the 2 values */
    450             bkpinfo->netfs_user = bkpinfo->netfs_mount;
     451            mr_asprintf(bkpinfo->netfs_user, "%s", bkpinfo->netfs_mount);
     452            p = strchr(bkpinfo->netfs_user, '@');
     453            *p = '\0';
     454            p = strchr(bkpinfo->netfs_mount, '@');
    451455            p++;
    452456            /* new netfs mount */
     457            q2 = bkpinfo->netfs_mount;
    453458            mr_asprintf(bkpinfo->netfs_mount, "%s", p);
    454             /* now that user is computed, create the right value by removing end of string */
    455             p--;
    456             *p = '\0';
     459            mr_free(q2);
    457460        }
    458461        if (bkpinfo->netfs_user != NULL) {
Note: See TracChangeset for help on using the changeset viewer.