Bug Summary

File:jdk/src/java.security.jgss/share/native/libj2gss/NativeFunc.c
Warning:line 274, column 5
Value stored to 'major' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name NativeFunc.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mthread-model posix -fno-delete-null-pointer-checks -mframe-pointer=all -relaxed-aliasing -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib/llvm-10/lib/clang/10.0.0 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/support/modules_include/java.base -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/support/modules_include/java.base/linux -I /home/daniel/Projects/java/jdk/src/java.base/share/native/libjava -I /home/daniel/Projects/java/jdk/src/java.base/unix/native/libjava -I /home/daniel/Projects/java/jdk/src/hotspot/share/include -I /home/daniel/Projects/java/jdk/src/hotspot/os/posix/include -D LIBC=gnu -D _GNU_SOURCE -D _REENTRANT -D _LARGEFILE64_SOURCE -D LINUX -D DEBUG -D _LITTLE_ENDIAN -D ARCH="amd64" -D amd64 -D _LP64=1 -I /home/daniel/Projects/java/jdk/src/java.security.jgss/share/native/libj2gss -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/support/headers/java.security.jgss -D _FORTIFY_SOURCE=2 -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-10/lib/clang/10.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wno-unused -Wno-undef -std=c99 -fdebug-compilation-dir /home/daniel/Projects/java/jdk/make -ferror-limit 19 -fmessage-length 0 -fvisibility hidden -stack-protector 1 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -o /home/daniel/Projects/java/scan/2021-12-21-193737-8510-1 -x c /home/daniel/Projects/java/jdk/src/java.security.jgss/share/native/libj2gss/NativeFunc.c
1/*
2 * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26#include <stdio.h>
27#include <stdlib.h>
28#include "NativeFunc.h"
29
30/* global GSS function table */
31GSS_FUNCTION_TABLE_PTR ftab;
32
33/* standard GSS method names (ordering is from mapfile) */
34static const char RELEASE_NAME[] = "gss_release_name";
35static const char IMPORT_NAME[] = "gss_import_name";
36static const char COMPARE_NAME[] = "gss_compare_name";
37static const char CANONICALIZE_NAME[] = "gss_canonicalize_name";
38static const char EXPORT_NAME[] = "gss_export_name";
39static const char DISPLAY_NAME[] = "gss_display_name";
40static const char ACQUIRE_CRED[] = "gss_acquire_cred";
41static const char RELEASE_CRED[] = "gss_release_cred";
42static const char INQUIRE_CRED[] = "gss_inquire_cred";
43static const char IMPORT_SEC_CONTEXT[] = "gss_import_sec_context";
44static const char INIT_SEC_CONTEXT[] = "gss_init_sec_context";
45static const char ACCEPT_SEC_CONTEXT[] = "gss_accept_sec_context";
46static const char INQUIRE_CONTEXT[] = "gss_inquire_context";
47static const char DELETE_SEC_CONTEXT[] = "gss_delete_sec_context";
48static const char CONTEXT_TIME[] = "gss_context_time";
49static const char WRAP_SIZE_LIMIT[] = "gss_wrap_size_limit";
50static const char EXPORT_SEC_CONTEXT[] = "gss_export_sec_context";
51static const char GET_MIC[] = "gss_get_mic";
52static const char VERIFY_MIC[] = "gss_verify_mic";
53static const char WRAP[] = "gss_wrap";
54static const char UNWRAP[] = "gss_unwrap";
55static const char INDICATE_MECHS[] = "gss_indicate_mechs";
56static const char INQUIRE_NAMES_FOR_MECH[] = "gss_inquire_names_for_mech";
57
58/* additional GSS methods not public thru mapfile */
59
60static const char ADD_OID_SET_MEMBER[] = "gss_add_oid_set_member";
61static const char DISPLAY_STATUS[] = "gss_display_status";
62static const char CREATE_EMPTY_OID_SET[] = "gss_create_empty_oid_set";
63static const char RELEASE_OID_SET[] = "gss_release_oid_set";
64static const char RELEASE_BUFFER[] = "gss_release_buffer";
65
66/**
67 * Initialize native GSS function pointers
68 */
69int loadNative(const char *libName) {
70
71 void *gssLib;
72 int failed;
73 OM_uint32 minor, major;
74
75 ftab = NULL((void*)0);
76 failed = FALSE0;
77
78 gssLib = GETLIB(libName)dlopen(libName, 0x00002);
79 if (gssLib == NULL((void*)0)) {
80 failed = TRUE1;
81 goto out;
82 }
83
84 /* global function table instance */
85 ftab = (GSS_FUNCTION_TABLE_PTR)malloc(sizeof(GSS_FUNCTION_TABLE));
86 if (ftab == NULL((void*)0)) {
87 failed = TRUE1;
88 goto out;
89 }
90
91 ftab->releaseName = (RELEASE_NAME_FN_PTR)GETFUNC(gssLib, RELEASE_NAME)dlsym(gssLib,RELEASE_NAME);
92 if (ftab->releaseName == NULL((void*)0)) {
93 failed = TRUE1;
94 goto out;
95 }
96
97 ftab->importName = (IMPORT_NAME_FN_PTR)GETFUNC(gssLib, IMPORT_NAME)dlsym(gssLib,IMPORT_NAME);
98 if (ftab->importName == NULL((void*)0)) {
99 failed = TRUE1;
100 goto out;
101 }
102
103 ftab->compareName = (COMPARE_NAME_FN_PTR)GETFUNC(gssLib, COMPARE_NAME)dlsym(gssLib,COMPARE_NAME);
104 if (ftab->compareName == NULL((void*)0)) {
105 failed = TRUE1;
106 goto out;
107 }
108
109 ftab->canonicalizeName = (CANONICALIZE_NAME_FN_PTR)
110 GETFUNC(gssLib, CANONICALIZE_NAME)dlsym(gssLib,CANONICALIZE_NAME);
111 if (ftab->canonicalizeName == NULL((void*)0)) {
112 failed = TRUE1;
113 goto out;
114 }
115
116 ftab->exportName = (EXPORT_NAME_FN_PTR)GETFUNC(gssLib, EXPORT_NAME)dlsym(gssLib,EXPORT_NAME);
117 if (ftab->exportName == NULL((void*)0)) {
118 failed = TRUE1;
119 goto out;
120 }
121
122 ftab->displayName = (DISPLAY_NAME_FN_PTR)GETFUNC(gssLib, DISPLAY_NAME)dlsym(gssLib,DISPLAY_NAME);
123 if (ftab->displayName == NULL((void*)0)) {
124 failed = TRUE1;
125 goto out;
126 }
127
128 ftab->acquireCred = (ACQUIRE_CRED_FN_PTR)GETFUNC(gssLib, ACQUIRE_CRED)dlsym(gssLib,ACQUIRE_CRED);
129 if (ftab->acquireCred == NULL((void*)0)) {
130 failed = TRUE1;
131 goto out;
132 }
133
134 ftab->releaseCred = (RELEASE_CRED_FN_PTR)GETFUNC(gssLib, RELEASE_CRED)dlsym(gssLib,RELEASE_CRED);
135 if (ftab->releaseCred == NULL((void*)0)) {
136 failed = TRUE1;
137 goto out;
138 }
139
140 ftab->inquireCred = (INQUIRE_CRED_FN_PTR)GETFUNC(gssLib, INQUIRE_CRED)dlsym(gssLib,INQUIRE_CRED);
141 if (ftab->inquireCred == NULL((void*)0)) {
142 failed = TRUE1;
143 goto out;
144 }
145
146 ftab->importSecContext = (IMPORT_SEC_CONTEXT_FN_PTR)
147 GETFUNC(gssLib, IMPORT_SEC_CONTEXT)dlsym(gssLib,IMPORT_SEC_CONTEXT);
148 if (ftab->importSecContext == NULL((void*)0)) {
149 failed = TRUE1;
150 goto out;
151 }
152
153 ftab->initSecContext = (INIT_SEC_CONTEXT_FN_PTR)
154 GETFUNC(gssLib, INIT_SEC_CONTEXT)dlsym(gssLib,INIT_SEC_CONTEXT);
155 if (ftab->initSecContext == NULL((void*)0)) {
156 failed = TRUE1;
157 goto out;
158 }
159
160 ftab->acceptSecContext = (ACCEPT_SEC_CONTEXT_FN_PTR)
161 GETFUNC(gssLib, ACCEPT_SEC_CONTEXT)dlsym(gssLib,ACCEPT_SEC_CONTEXT);
162 if (ftab->acceptSecContext == NULL((void*)0)) {
163 failed = TRUE1;
164 goto out;
165 }
166
167 ftab->inquireContext = (INQUIRE_CONTEXT_FN_PTR)
168 GETFUNC(gssLib, INQUIRE_CONTEXT)dlsym(gssLib,INQUIRE_CONTEXT);
169 if (ftab->inquireContext == NULL((void*)0)) {
170 failed = TRUE1;
171 goto out;
172 }
173
174 ftab->deleteSecContext = (DELETE_SEC_CONTEXT_FN_PTR)
175 GETFUNC(gssLib, DELETE_SEC_CONTEXT)dlsym(gssLib,DELETE_SEC_CONTEXT);
176 if (ftab->deleteSecContext == NULL((void*)0)) {
177 failed = TRUE1;
178 goto out;
179 }
180
181 ftab->contextTime = (CONTEXT_TIME_FN_PTR)GETFUNC(gssLib, CONTEXT_TIME)dlsym(gssLib,CONTEXT_TIME);
182 if (ftab->contextTime == NULL((void*)0)) {
183 failed = TRUE1;
184 goto out;
185 }
186
187 ftab->wrapSizeLimit = (WRAP_SIZE_LIMIT_FN_PTR)
188 GETFUNC(gssLib, WRAP_SIZE_LIMIT)dlsym(gssLib,WRAP_SIZE_LIMIT);
189 if (ftab->wrapSizeLimit == NULL((void*)0)) {
190 failed = TRUE1;
191 goto out;
192 }
193
194 ftab->exportSecContext = (EXPORT_SEC_CONTEXT_FN_PTR)
195 GETFUNC(gssLib, EXPORT_SEC_CONTEXT)dlsym(gssLib,EXPORT_SEC_CONTEXT);
196 if (ftab->exportSecContext == NULL((void*)0)) {
197 failed = TRUE1;
198 goto out;
199 }
200
201 ftab->getMic = (GET_MIC_FN_PTR)GETFUNC(gssLib, GET_MIC)dlsym(gssLib,GET_MIC);
202 if (ftab->getMic == NULL((void*)0)) {
203 failed = TRUE1;
204 goto out;
205 }
206
207 ftab->verifyMic = (VERIFY_MIC_FN_PTR)GETFUNC(gssLib, VERIFY_MIC)dlsym(gssLib,VERIFY_MIC);
208 if (ftab->verifyMic == NULL((void*)0)) {
209 failed = TRUE1;
210 goto out;
211 }
212
213 ftab->wrap = (WRAP_FN_PTR)GETFUNC(gssLib, WRAP)dlsym(gssLib,WRAP);
214 if (ftab->wrap == NULL((void*)0)) {
215 failed = TRUE1;
216 goto out;
217 }
218
219 ftab->unwrap = (UNWRAP_FN_PTR)GETFUNC(gssLib, UNWRAP)dlsym(gssLib,UNWRAP);
220 if (ftab->unwrap == NULL((void*)0)) {
221 failed = TRUE1;
222 goto out;
223 }
224
225 ftab->indicateMechs = (INDICATE_MECHS_FN_PTR)GETFUNC(gssLib, INDICATE_MECHS)dlsym(gssLib,INDICATE_MECHS);
226 if (ftab->indicateMechs == NULL((void*)0)) {
227 failed = TRUE1;
228 goto out;
229 }
230
231 ftab->inquireNamesForMech = (INQUIRE_NAMES_FOR_MECH_FN_PTR)
232 GETFUNC(gssLib, INQUIRE_NAMES_FOR_MECH)dlsym(gssLib,INQUIRE_NAMES_FOR_MECH);
233 if (ftab->inquireNamesForMech == NULL((void*)0)) {
234 failed = TRUE1;
235 goto out;
236 }
237
238 ftab->addOidSetMember = (ADD_OID_SET_MEMBER_FN_PTR)
239 GETFUNC(gssLib, ADD_OID_SET_MEMBER)dlsym(gssLib,ADD_OID_SET_MEMBER);
240 if (ftab->addOidSetMember == NULL((void*)0)) {
241 failed = TRUE1;
242 goto out;
243 }
244
245 ftab->displayStatus = (DISPLAY_STATUS_FN_PTR)
246 GETFUNC(gssLib, DISPLAY_STATUS)dlsym(gssLib,DISPLAY_STATUS);
247 if (ftab->displayStatus == NULL((void*)0)) {
248 failed = TRUE1;
249 goto out;
250 }
251
252 ftab->createEmptyOidSet = (CREATE_EMPTY_OID_SET_FN_PTR)
253 GETFUNC(gssLib, CREATE_EMPTY_OID_SET)dlsym(gssLib,CREATE_EMPTY_OID_SET);
254 if (ftab->createEmptyOidSet == NULL((void*)0)) {
255 failed = TRUE1;
256 goto out;
257 }
258
259 ftab->releaseOidSet = (RELEASE_OID_SET_FN_PTR)
260 GETFUNC(gssLib, RELEASE_OID_SET)dlsym(gssLib,RELEASE_OID_SET);
261 if (ftab->releaseOidSet == NULL((void*)0)) {
262 failed = TRUE1;
263 goto out;
264 }
265
266 ftab->releaseBuffer = (RELEASE_BUFFER_FN_PTR)
267 GETFUNC(gssLib, RELEASE_BUFFER)dlsym(gssLib,RELEASE_BUFFER);
268 if (ftab->releaseBuffer == NULL((void*)0)) {
269 failed = TRUE1;
270 goto out;
271 }
272
273 ftab->mechs = GSS_C_NO_OID_SET((gss_OID_set) 0);
274 major = (*ftab->indicateMechs)(&minor, &(ftab->mechs));
Value stored to 'major' is never read
275 if (ftab->mechs == NULL((void*)0) || ftab->mechs == GSS_C_NO_OID_SET((gss_OID_set) 0)) {
276 failed = TRUE1;
277 goto out;
278 }
279
280
281out:
282 if (failed == TRUE1) {
283 if (gssLib != NULL((void*)0)) CLOSELIB(gssLib)dlclose(gssLib);
284 if (ftab != NULL((void*)0)) free(ftab);
285 }
286 return failed;
287}