diff options
author | Michael Vogt <mvo@debian.org> | 2011-05-16 15:57:52 +0200 |
---|---|---|
committer | Michael Vogt <mvo@debian.org> | 2011-05-16 15:57:52 +0200 |
commit | d44b706c2d5964daaaf55e6eb97845827958f6e3 (patch) | |
tree | b77f6e72c34c2444ec28e2d47430211d802efb4b /apt-pkg/contrib | |
parent | 9c192d2811c12dcaf607024eb7f0677b011194e6 (diff) | |
parent | d77b985a309c379d4978525172a72b728fecd15e (diff) |
merged from lp:~donkult/apt/sid
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r-- | apt-pkg/contrib/cdromutl.cc | 16 | ||||
-rw-r--r-- | apt-pkg/contrib/error.cc | 2 | ||||
-rw-r--r-- | apt-pkg/contrib/mmap.cc | 8 | ||||
-rw-r--r-- | apt-pkg/contrib/netrc.cc | 12 |
4 files changed, 28 insertions, 10 deletions
diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc index 83c324f54..821e6d688 100644 --- a/apt-pkg/contrib/cdromutl.cc +++ b/apt-pkg/contrib/cdromutl.cc @@ -20,7 +20,6 @@ #include <apti18n.h> #include <sys/wait.h> -#include <sys/errno.h> #include <sys/statvfs.h> #include <dirent.h> #include <fcntl.h> @@ -206,8 +205,11 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version) Hash.Add(Dir->d_name); }; - if (chdir(StartDir.c_str()) != 0) - return _error->Errno("chdir",_("Unable to change to %s"),StartDir.c_str()); + if (chdir(StartDir.c_str()) != 0) { + _error->Errno("chdir",_("Unable to change to %s"),StartDir.c_str()); + closedir(D); + return false; + } closedir(D); // Some stats from the fsys @@ -236,7 +238,7 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version) } /*}}}*/ -// FindMountPointForDevice - Find mountpoint for the given device /*{{{*/ +// FindMountPointForDevice - Find mountpoint for the given device /*{{{*/ string FindMountPointForDevice(const char *devnode) { char buf[255]; @@ -254,7 +256,10 @@ string FindMountPointForDevice(const char *devnode) while ( fgets(buf, sizeof(buf), f) != NULL) { if (strncmp(buf, devnode, strlen(devnode)) == 0) { if(TokSplitString(' ', buf, out, 10)) + { + fclose(f); return string(out[1]); + } } } fclose(f); @@ -263,5 +268,4 @@ string FindMountPointForDevice(const char *devnode) return string(); } - - + /*}}}*/ diff --git a/apt-pkg/contrib/error.cc b/apt-pkg/contrib/error.cc index fe50e606b..18810d2a4 100644 --- a/apt-pkg/contrib/error.cc +++ b/apt-pkg/contrib/error.cc @@ -107,6 +107,7 @@ bool GlobalError::InsertErrno(MsgType type, const char* Function, msgSize = n + 1; else msgSize *= 2; + free(S); return true; } @@ -160,6 +161,7 @@ bool GlobalError::Insert(MsgType type, const char* Description, msgSize = n + 1; else msgSize *= 2; + free(S); return true; } diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc index 9945b1606..19381ae47 100644 --- a/apt-pkg/contrib/mmap.cc +++ b/apt-pkg/contrib/mmap.cc @@ -237,11 +237,19 @@ DynamicMMap::DynamicMMap(unsigned long Flags,unsigned long const &WorkSpace, if ((this->Flags & Fallback) != Fallback) { // Set the permissions. int Prot = PROT_READ; +#ifdef MAP_ANONYMOUS int Map = MAP_PRIVATE | MAP_ANONYMOUS; +#else + int Map = MAP_PRIVATE | MAP_ANON; +#endif if ((this->Flags & ReadOnly) != ReadOnly) Prot |= PROT_WRITE; if ((this->Flags & Public) == Public) +#ifdef MAP_ANONYMOUS Map = MAP_SHARED | MAP_ANONYMOUS; +#else + Map = MAP_SHARED | MAP_ANON; +#endif // use anonymous mmap() to get the memory Base = (unsigned char*) mmap(0, WorkSpace, Prot, Map, -1, 0); diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc index d8027fc24..34f472ee1 100644 --- a/apt-pkg/contrib/netrc.cc +++ b/apt-pkg/contrib/netrc.cc @@ -160,10 +160,10 @@ void maybe_add_auth (URI &Uri, string NetRCFile) { char login[64] = ""; char password[64] = ""; - char *netrcfile = strdupa (NetRCFile.c_str ()); + char *netrcfile = strdup(NetRCFile.c_str()); // first check for a generic host based netrc entry - char *host = strdupa (Uri.Host.c_str ()); + char *host = strdup(Uri.Host.c_str()); if (host && parsenetrc (host, login, password, netrcfile) == 0) { if (_config->FindB("Debug::Acquire::netrc", false) == true) @@ -173,13 +173,16 @@ void maybe_add_auth (URI &Uri, string NetRCFile) << std::endl; Uri.User = string (login); Uri.Password = string (password); + free(netrcfile); + free(host); return; } + free(host); // if host did not work, try Host+Path next, this will trigger // a lookup uri.startswith(host) in the netrc file parser (because // of the "/" - char *hostpath = strdupa (string(Uri.Host+Uri.Path).c_str ()); + char *hostpath = strdup(string(Uri.Host+Uri.Path).c_str()); if (hostpath && parsenetrc (hostpath, login, password, netrcfile) == 0) { if (_config->FindB("Debug::Acquire::netrc", false) == true) @@ -189,8 +192,9 @@ void maybe_add_auth (URI &Uri, string NetRCFile) << std::endl; Uri.User = string (login); Uri.Password = string (password); - return; } + free(netrcfile); + free(hostpath); } } } |