Ignore:
Timestamp:
May 24, 2009, 7:17:10 AM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update Samba 3.3 to 3.3.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.3.x/source/client/umount.cifs.c

    r206 r221  
    3434#include <string.h>
    3535#include <mntent.h>
     36#include <limits.h>
    3637#include "mount.h"
    3738
     
    232233}
    233234
     235/* Make a canonical pathname from PATH.  Returns a freshly malloced string.
     236   It is up the *caller* to ensure that the PATH is sensible.  i.e.
     237   canonicalize ("/dev/fd0/.") returns "/dev/fd0" even though ``/dev/fd0/.''
     238   is not a legal pathname for ``/dev/fd0''  Anything we cannot parse
     239   we return unmodified.   */
     240static char *
     241canonicalize(char *path)
     242{
     243        char *canonical;
     244
     245        if (path == NULL) {
     246                return NULL;
     247        }
     248
     249        if (strlen(path) > PATH_MAX) {
     250                fprintf(stderr, "Mount point string too long\n");
     251                return NULL;
     252        }
     253
     254        canonical = (char *)malloc (PATH_MAX + 1);
     255
     256        if (!canonical) {
     257                fprintf(stderr, "Error! Not enough memory!\n");
     258                return NULL;
     259        }
     260
     261        if (realpath (path, canonical))
     262                return canonical;
     263
     264        strncpy (canonical, path, PATH_MAX);
     265        canonical[PATH_MAX] = '\0';
     266        return canonical;
     267}
     268
    234269int main(int argc, char ** argv)
    235270{
     
    305340        argc -= optind;
    306341
    307         mountpoint = argv[0];
     342        mountpoint = canonicalize(argv[0]);
    308343
    309344        if((argc < 1) || (argv[0] == NULL)) {
Note: See TracChangeset for help on using the changeset viewer.