aboutsummaryrefslogtreecommitdiffstats
path: root/tools/net/ynl/generated/netdev-user.c
diff options
context:
space:
mode:
authorGeorgi Valkov <[email protected]>2023-06-07 13:56:59 +0000
committerDavid S. Miller <[email protected]>2023-06-09 09:26:57 +0000
commit2203718c2f59ffdd6c78d54e5add594aebb4461e (patch)
tree8e909ff2119179b861f0ad8d6132d2f099b7ad8a /tools/net/ynl/generated/netdev-user.c
parentMerge branch 'splice-net-rewrite-splice-to-socket-fix-splice_f_more-and-handl... (diff)
downloadkernel-2203718c2f59ffdd6c78d54e5add594aebb4461e.tar.gz
kernel-2203718c2f59ffdd6c78d54e5add594aebb4461e.zip
usbnet: ipheth: fix risk of NULL pointer deallocation
The cleanup precedure in ipheth_probe will attempt to free a NULL pointer in dev->ctrl_buf if the memory allocation for this buffer is not successful. While kfree ignores NULL pointers, and the existing code is safe, it is a better design to rearrange the goto labels and avoid this. Signed-off-by: Georgi Valkov <[email protected]> Signed-off-by: Foster Snowhill <[email protected]> Signed-off-by: David S. Miller <[email protected]>
Diffstat (limited to 'tools/net/ynl/generated/netdev-user.c')
0 files changed, 0 insertions, 0 deletions
id='n80' href='#n80'>80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
/**
 * Copyright (C) 2021-2024 Saturneric <eric@bktus.com>
 *
 * This file is part of GpgFrontend.
 *
 * GpgFrontend is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * GpgFrontend is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
 *
 * The initial version of the source code is inherited from
 * the gpg4usb project, which is under GPL-3.0-or-later.
 *
 * All the source code of GpgFrontend was modified and released by
 * Saturneric <eric@bktus.com> starting on May 12, 2021.
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 */

#include <gtest/gtest.h>

#include "GpgCoreTest.h"
#include "core/function/gpg/GpgContext.h"
#include "core/function/gpg/GpgKeyGetter.h"
#include "core/model/GpgData.h"
#include "core/model/GpgKey.h"
#include "core/utils/GpgUtils.h"

namespace GpgFrontend::Test {

TEST_F(GpgCoreTest, CoreInitTest) {
  auto& ctx = GpgContext::GetInstance(kGpgFrontendDefaultChannel);
  auto& ctx_default = GpgContext::GetInstance();
  ASSERT_TRUE(ctx.Good());
  ASSERT_TRUE(ctx_default.Good());
}

TEST_F(GpgCoreTest, GpgDataTest) {
  auto data_buff = QString(
      "cqEh8fyKWtmiXrW2zzlszJVGJrpXDDpzgP7ZELGxhfZYFi8rMrSVKDwrpFZBSWMG");

  GpgData data(data_buff.data(), data_buff.size());

  auto out_buffer = data.Read2GFBuffer();
  ASSERT_EQ(out_buffer.Size(), 64);
}

TEST_F(GpgCoreTest, GpgKeyTest) {
  auto key = GpgKeyGetter::GetInstance(kGpgFrontendDefaultChannel)
                 .GetKey("9490795B78F8AFE9F93BD09281704859182661FB");
  ASSERT_TRUE(key.IsGood());
  ASSERT_TRUE(key.IsPrivateKey());
  ASSERT_TRUE(key.IsHasMasterKey());

  ASSERT_FALSE(key.IsDisabled());
  ASSERT_FALSE(key.IsRevoked());

  ASSERT_EQ(key.GetProtocol(), "OpenPGP");

  ASSERT_EQ(key.GetSubKeys()->size(), 2);
  ASSERT_EQ(key.GetUIDs()->size(), 1);

  ASSERT_TRUE(key.IsHasCertificationCapability());
  ASSERT_FALSE(key.IsHasEncryptionCapability());
  ASSERT_TRUE(key.IsHasSigningCapability());
  ASSERT_FALSE(key.IsHasAuthenticationCapability());
  ASSERT_FALSE(key.IsHasActualCertificationCapability());
  ASSERT_FALSE(key.IsHasActualEncryptionCapability());
  ASSERT_FALSE(key.IsHasActualSigningCapability());
  ASSERT_FALSE(key.IsHasActualAuthenticationCapability());

  ASSERT_EQ(key.GetName(), "GpgFrontendTest");
  ASSERT_TRUE(key.GetComment().isEmpty());
  ASSERT_EQ(key.GetEmail(), "gpgfrontend@gpgfrontend.pub");
  ASSERT_EQ(key.GetId(), "81704859182661FB");
  ASSERT_EQ(key.GetFingerprint(), "9490795B78F8AFE9F93BD09281704859182661FB");
  ASSERT_EQ(key.GetExpireTime(),
            QDateTime::fromString("2023-09-05T04:00:00Z", Qt::ISODate));
  ASSERT_EQ(key.GetPublicKeyAlgo(), "RSA");
  ASSERT_EQ(key.GetKeyAlgo(), "RSA3072");
  ASSERT_EQ(key.GetPrimaryKeyLength(), 3072);
  ASSERT_EQ(key.GetLastUpdateTime(),
            QDateTime::fromString("1970-01-01T00:00:00Z", Qt::ISODate));
  ASSERT_EQ(key.GetCreateTime(),
            QDateTime::fromString("2021-09-05T06:01:53Z", Qt::ISODate));

  ASSERT_EQ(key.GetOwnerTrust(), "Unknown");
  ASSERT_EQ(key.IsExpired(),
            key.GetExpireTime() < QDateTime::currentDateTime());
}

TEST_F(GpgCoreTest, GpgSubKeyTest) {
  auto key = GpgKeyGetter::GetInstance(kGpgFrontendDefaultChannel)
                 .GetKey("9490795B78F8AFE9F93BD09281704859182661FB");
  auto sub_keys = key.GetSubKeys();
  ASSERT_EQ(sub_keys->size(), 2);

  auto& main_key = sub_keys->front();

  ASSERT_EQ(main_key.GetID(), "81704859182661FB");
  ASSERT_EQ(main_key.GetFingerprint(),
            "9490795B78F8AFE9F93BD09281704859182661FB");
  ASSERT_EQ(main_key.GetExpireTime(),