Ignore:
Timestamp:
Aug 5, 2009, 6:34:45 PM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update 3.0 to final 3.0.36 (source)

File:
1 edited

Legend:

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

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