Path: blob/main/crypto/krb5/src/lib/gssapi/generic/util_buffer.c
39563 views
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */1/*2* Copyright 1993 by OpenVision Technologies, Inc.3*4* Permission to use, copy, modify, distribute, and sell this software5* and its documentation for any purpose is hereby granted without fee,6* provided that the above copyright notice appears in all copies and7* that both that copyright notice and this permission notice appear in8* supporting documentation, and that the name of OpenVision not be used9* in advertising or publicity pertaining to distribution of the software10* without specific, written prior permission. OpenVision makes no11* representations about the suitability of this software for any12* purpose. It is provided "as is" without express or implied warranty.13*14* OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,15* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO16* EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR17* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF18* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR19* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR20* PERFORMANCE OF THIS SOFTWARE.21*/2223/*24* $Id$25*/2627#include "gssapiP_generic.h"28#include <string.h>2930/* return nonzero on success, 0 on failure31make sure that buffer is consistent (release'able) when this32function exits, no matter what the exit value */3334int g_make_string_buffer(const char *str, gss_buffer_t buffer)35{36if (buffer == GSS_C_NO_BUFFER)37return (1);3839buffer->length = strlen(str);4041if ((buffer->value = gssalloc_strdup(str)) == NULL) {42buffer->length = 0;43return(0);44}4546return(1);47}484950