Initialize uid and gid fields of NetherPacket 73/129473/11
authorPiotr Sawicki <p.sawicki2@partner.samsung.com>
Tue, 16 May 2017 10:38:34 +0000 (12:38 +0200)
committerZofia Abramowska <z.abramowska@samsung.com>
Mon, 29 May 2017 12:56:07 +0000 (14:56 +0200)
Under some circumstances, Nether may receive netlink packets which
don't contain uid and gid fields (e.g. IGMP packets generated by
the kernel). Prior to this change, uid and gid fields were not
properly initialized because the nfq_get_uid() and nfq_get_gid()
functions don't modify their second argument in case of an absence
of the UID/GID fields in an input packet.

Change-Id: I712d44a4eccb3603fdf5d8279e7eb1f49e8f34a7

include/nether_Types.h

index 7a85bb8..2524bb9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2015 - 2017 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Contact: Roman Kubiak (r.kubiak@samsung.com)
  *
@@ -150,12 +150,12 @@ enum class NetherProtocolType : std::uint8_t
 
 struct NetherPacket
 {
-       uid_t uid;
+       uid_t uid                                                                               = NETHER_INVALID_UID;
        u_int32_t id;
        std::string securityContext;
        int32_t remotePort                                                              = -1;
        int32_t localPort                                                               = -1;
-       gid_t gid;
+       gid_t gid                                                                               = NETHER_INVALID_GID;
        pid_t pid;
        char localAddress[NETHER_NETWORK_ADDR_LEN]              = {0};
        char remoteAddress[NETHER_NETWORK_ADDR_LEN]             = {0};