Changeset View
Changeset View
Standalone View
Standalone View
src/ioslaves/file/sharefd_p.h
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | 37 | public: | |||
---|---|---|---|---|---|
50 | } | 50 | } | ||
51 | 51 | | |||
52 | private: | 52 | private: | ||
53 | static sockaddr_un make_address(const std::string& path) | 53 | static sockaddr_un make_address(const std::string& path) | ||
54 | { | 54 | { | ||
55 | sockaddr_un a; | 55 | sockaddr_un a; | ||
56 | memset(&a, 0, sizeof a); | 56 | memset(&a, 0, sizeof a); | ||
57 | a.sun_family = AF_UNIX; | 57 | a.sun_family = AF_UNIX; | ||
58 | std::string finalPath = "/tmp/" + path; | 58 | const size_t pathSize = path.size(); | ||
59 | const size_t pathSize = finalPath.size(); | 59 | if (pathSize > 0 && pathSize < sizeof(a.sun_path) - 1) { | ||
60 | if (pathSize > 5 && pathSize < sizeof(a.sun_path) - 1) { | 60 | memcpy(a.sun_path, path.c_str(), pathSize + 1); | ||
61 | memcpy(a.sun_path, finalPath.c_str(), pathSize + 1); | | |||
62 | } | 61 | } | ||
63 | return a; | 62 | return a; | ||
64 | } | 63 | } | ||
65 | }; | 64 | }; | ||
66 | 65 | | |||
67 | class FDMessageHeader | 66 | class FDMessageHeader | ||
68 | { | 67 | { | ||
69 | char io_buf[2]; | 68 | char io_buf[2]; | ||
Show All 30 Lines |