From owner-svn-src-all@freebsd.org Wed Apr 13 21:08:04 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 91499B0F16C; Wed, 13 Apr 2016 21:08:04 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6CFB71705; Wed, 13 Apr 2016 21:08:04 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u3DL83Hl094020; Wed, 13 Apr 2016 21:08:03 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u3DL82O0094011; Wed, 13 Apr 2016 21:08:02 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201604132108.u3DL82O0094011@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Wed, 13 Apr 2016 21:08:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r297942 - head/lib/libgssapi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Apr 2016 21:08:04 -0000 Author: pfg Date: Wed Apr 13 21:08:02 2016 New Revision: 297942 URL: https://svnweb.freebsd.org/changeset/base/297942 Log: libgssapi: avoid NULL pointer dereferences. While here also use NULL instead of zero for pointers. Found with coccinelle. MFC after: 1 week Modified: head/lib/libgssapi/gss_add_cred.c head/lib/libgssapi/gss_encapsulate_token.c head/lib/libgssapi/gss_get_mic.c head/lib/libgssapi/gss_inquire_context.c head/lib/libgssapi/gss_mech_switch.c head/lib/libgssapi/gss_pseudo_random.c head/lib/libgssapi/gss_verify_mic.c head/lib/libgssapi/gss_wrap.c head/lib/libgssapi/gss_wrap_size_limit.c Modified: head/lib/libgssapi/gss_add_cred.c ============================================================================== --- head/lib/libgssapi/gss_add_cred.c Wed Apr 13 21:01:58 2016 (r297941) +++ head/lib/libgssapi/gss_add_cred.c Wed Apr 13 21:08:02 2016 (r297942) @@ -121,7 +121,7 @@ gss_add_cred(OM_uint32 *minor_status, * gss_add_cred for that mechanism, otherwise we copy the mc * to new_cred. */ - target_mc = 0; + target_mc = NULL; if (cred) { SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) { if (gss_oid_equal(mc->gmc_mech_oid, desired_mech)) { @@ -151,7 +151,7 @@ gss_add_cred(OM_uint32 *minor_status, return (major_status); } } else { - mn = 0; + mn = NULL; } m = _gss_find_mech_switch(desired_mech); Modified: head/lib/libgssapi/gss_encapsulate_token.c ============================================================================== --- head/lib/libgssapi/gss_encapsulate_token.c Wed Apr 13 21:01:58 2016 (r297941) +++ head/lib/libgssapi/gss_encapsulate_token.c Wed Apr 13 21:08:02 2016 (r297942) @@ -47,7 +47,7 @@ gss_encapsulate_token(const gss_buffer_t * First time around, we calculate the size, second time, we * encode the token. */ - p = 0; + p = NULL; for (i = 0; i < 2; i++) { len = 0; Modified: head/lib/libgssapi/gss_get_mic.c ============================================================================== --- head/lib/libgssapi/gss_get_mic.c Wed Apr 13 21:01:58 2016 (r297941) +++ head/lib/libgssapi/gss_get_mic.c Wed Apr 13 21:08:02 2016 (r297942) @@ -40,13 +40,14 @@ gss_get_mic(OM_uint32 *minor_status, gss_buffer_t message_token) { struct _gss_context *ctx = (struct _gss_context *) context_handle; - struct _gss_mech_switch *m = ctx->gc_mech; + struct _gss_mech_switch *m; _gss_buffer_zero(message_token); if (ctx == NULL) { *minor_status = 0; return (GSS_S_NO_CONTEXT); } + m = ctx->gc_mech; return (m->gm_get_mic(minor_status, ctx->gc_ctx, qop_req, message_buffer, message_token)); Modified: head/lib/libgssapi/gss_inquire_context.c ============================================================================== --- head/lib/libgssapi/gss_inquire_context.c Wed Apr 13 21:01:58 2016 (r297941) +++ head/lib/libgssapi/gss_inquire_context.c Wed Apr 13 21:08:02 2016 (r297942) @@ -99,7 +99,7 @@ gss_inquire_context(OM_uint32 *minor_sta if (src_name) gss_release_name(minor_status, src_name); m->gm_release_name(minor_status, &src_mn); - minor_status = 0; + minor_status = NULL; return (GSS_S_FAILURE); } *targ_name = (gss_name_t) name; Modified: head/lib/libgssapi/gss_mech_switch.c ============================================================================== --- head/lib/libgssapi/gss_mech_switch.c Wed Apr 13 21:01:58 2016 (r297941) +++ head/lib/libgssapi/gss_mech_switch.c Wed Apr 13 21:08:02 2016 (r297942) @@ -83,7 +83,7 @@ _gss_string_to_oid(const char* s, gss_OI * out the size. Second time around, we actually encode the * number. */ - res = 0; + res = NULL; for (i = 0; i < 2; i++) { byte_count = 0; for (p = s, j = 0; p; p = q, j++) { Modified: head/lib/libgssapi/gss_pseudo_random.c ============================================================================== --- head/lib/libgssapi/gss_pseudo_random.c Wed Apr 13 21:01:58 2016 (r297941) +++ head/lib/libgssapi/gss_pseudo_random.c Wed Apr 13 21:08:02 2016 (r297942) @@ -48,7 +48,7 @@ gss_pseudo_random(OM_uint32 *minor_statu gss_buffer_t prf_out) { struct _gss_context *ctx = (struct _gss_context *) context; - struct _gss_mech_switch *m = ctx->gc_mech; + struct _gss_mech_switch *m; OM_uint32 major_status; _gss_buffer_zero(prf_out); @@ -58,6 +58,7 @@ gss_pseudo_random(OM_uint32 *minor_statu *minor_status = 0; return GSS_S_NO_CONTEXT; } + m = ctx->gc_mech; if (m->gm_pseudo_random == NULL) return GSS_S_UNAVAILABLE; Modified: head/lib/libgssapi/gss_verify_mic.c ============================================================================== --- head/lib/libgssapi/gss_verify_mic.c Wed Apr 13 21:01:58 2016 (r297941) +++ head/lib/libgssapi/gss_verify_mic.c Wed Apr 13 21:08:02 2016 (r297942) @@ -39,7 +39,7 @@ gss_verify_mic(OM_uint32 *minor_status, gss_qop_t *qop_state) { struct _gss_context *ctx = (struct _gss_context *) context_handle; - struct _gss_mech_switch *m = ctx->gc_mech; + struct _gss_mech_switch *m; if (qop_state) *qop_state = 0; @@ -47,6 +47,7 @@ gss_verify_mic(OM_uint32 *minor_status, *minor_status = 0; return (GSS_S_NO_CONTEXT); } + m = ctx->gc_mech; return (m->gm_verify_mic(minor_status, ctx->gc_ctx, message_buffer, token_buffer, qop_state)); Modified: head/lib/libgssapi/gss_wrap.c ============================================================================== --- head/lib/libgssapi/gss_wrap.c Wed Apr 13 21:01:58 2016 (r297941) +++ head/lib/libgssapi/gss_wrap.c Wed Apr 13 21:08:02 2016 (r297942) @@ -42,7 +42,7 @@ gss_wrap(OM_uint32 *minor_status, gss_buffer_t output_message_buffer) { struct _gss_context *ctx = (struct _gss_context *) context_handle; - struct _gss_mech_switch *m = ctx->gc_mech; + struct _gss_mech_switch *m; if (conf_state) *conf_state = 0; @@ -51,6 +51,7 @@ gss_wrap(OM_uint32 *minor_status, *minor_status = 0; return (GSS_S_NO_CONTEXT); } + m = ctx->gc_mech; return (m->gm_wrap(minor_status, ctx->gc_ctx, conf_req_flag, qop_req, input_message_buffer, Modified: head/lib/libgssapi/gss_wrap_size_limit.c ============================================================================== --- head/lib/libgssapi/gss_wrap_size_limit.c Wed Apr 13 21:01:58 2016 (r297941) +++ head/lib/libgssapi/gss_wrap_size_limit.c Wed Apr 13 21:08:02 2016 (r297942) @@ -40,13 +40,14 @@ gss_wrap_size_limit(OM_uint32 *minor_sta OM_uint32 *max_input_size) { struct _gss_context *ctx = (struct _gss_context *) context_handle; - struct _gss_mech_switch *m = ctx->gc_mech; + struct _gss_mech_switch *m; *max_input_size = 0; if (ctx == NULL) { *minor_status = 0; return (GSS_S_NO_CONTEXT); } + m = ctx->gc_mech; return (m->gm_wrap_size_limit(minor_status, ctx->gc_ctx, conf_req_flag, qop_req, req_output_size, max_input_size));