if (!confirm) return (1); /* no confirm, just die */
if (gethostname (hostname, sizeof(hostname)-1) != 0)
- strcpy (hostname, "???");
+ strlcpy (hostname, "???", sizeof(hostname));
else
hostname[sizeof(hostname)-1] = '\0';
}
#ifdef KRB5_KRB4_COMPAT
- strcpy(v4_instance, "*");
+ strlcpy(v4_instance, "*", sizeof(v4_instance));
#endif
if ((status = krb5_auth_con_init(bsd_context, &auth_context)))
#endif
#ifdef KRB5_KRB4_COMPAT
- strcpy(v4_instance, "*");
+ strlcpy(v4_instance, "*", sizeof(v4_instance));
#endif
status = krb5_auth_con_init(bsd_context, &auth_context);
* Assume it to be the same as the first component of the
* principal's name.
*/
- strcpy(remuser, v4_kdata->pname);
+ strlcpy(remuser, v4_kdata->pname, sizeof(remuser));
status = krb5_425_conv_principal(bsd_context, v4_kdata->pname,
v4_kdata->pinst, v4_kdata->prealm,
kdata = (AUTH_DAT *)malloc( sizeof(AUTH_DAT) );
ticket = (KTEXT) malloc(sizeof(KTEXT_ST));
- (void) strcpy(instance, "*");
+ (void) strlcpy(instance, "*", sizeof(instance));
if ((rc=krb_recvauth(authoptions, 0, ticket, "rcmd",
instance, &sin,
(struct sockaddr_in *)0,
}
#endif
- strcpy(instance, "*");
+ strlcpy(instance, "*", sizeof(instance));
/* If rshd was invoked with the -s argument, it will set the
environment variable KRB_SRVTAB. We use that to get the
form = FORM_N;
mode = MODE_S;
stru = STRU_F;
- (void) strcpy(bytename, "8"), bytesize = 8;
+ (void) strlcpy(bytename, "8", sizeof(bytename)), bytesize = 8;
if (autoauth) {
if (do_auth() && autoencrypt) {
clevel = PROT_P;
#define L_INCR 1
#endif
+#include <k5-platform.h>
+
#ifdef KRB5_KRB4_COMPAT
#include <krb.h>
return(1);
for (n = 0; n < macnum; ++n) {
if (!strcmp("init", macros[n].mac_name)) {
- (void) strcpy(line, "$init");
+ (void) strlcpy(line, "$init", sizeof(line));
makeargv();
domacro(margc, margv);
break;
char *mhome;
{
register struct passwd *pp = getpwnam(mhome);
+ size_t bufsize = lastgpathp - mhome;
- if (!pp || ((mhome + strlen(pp->pw_dir)) >= lastgpathp))
+ if (!pp)
+ return (1);
+ if (strlcpy(mhome, pp->pw_dir, bufsize) >= bufsize)
return (1);
- (void) strcpy(mhome, pp->pw_dir);
return (0);
}
#endif
/* cast size to long in case sizeof(off_t) > sizeof(long) */
(void) sprintf (sizebuf, " (%ld bytes)", (long)size);
else
- (void) strcpy(sizebuf, "");
+ sizebuf[0] = '\0';
if (pdata >= 0) {
int s, fromlen = sizeof(data_dest);
strunames[stru], modenames[mode]);
reply(0, "%s", str);
if (data != -1)
- strcpy(str, " Data connection open");
+ strlcpy(str, " Data connection open", sizeof(str));
else if (pdata != -1) {
- strcpy(str, " in Passive mode");
+ strlcpy(str, " in Passive mode", sizeof(str));
sin4 = &pasv_addr;
goto printaddr;
} else if (usedefault == 0) {
UC(p[1]));
#undef UC
} else
- strcpy(str, " No data connection");
+ strlcpy(str, " No data connection", sizeof(str));
reply(0, "%s", str);
reply(211, "End of status");
}
return(0);
}
(void) memcpy((char *)ticket.dat, (char *)out_buf, ticket.length = length);
- strcpy(instance, "*");
+ strlcpy(instance, "*", sizeof(instance));
kerror = 255;
for (service = krb4_services; *service; service++) {
#include "com_err.h"
#include "libpty.h"
#include "pty-int.h"
+#include "k5-platform.h"
long
ptyint_getpty_ext(int *fd, char *slave, int slavelength, int do_grantpt)
*fd = -1;
return PTY_GETPTY_NOPTY;
}
- if (strlen(slaveret) > slavelength - 1) {
+ if (strlcpy(slave, slaveret, slavelength) >= slavelength) {
close(*fd);
*fd = -1;
return PTY_GETPTY_SLAVE_TOOLONG;
}
- else strcpy(slave, slaveret);
return 0;
#else /*HAVE__GETPTY*/
#endif
#endif
if (p) {
- if (strlen(p) > slavelength - 1) {
+ if (strlcpy(slave, p, slavelength) >= slavelength) {
close (*fd);
*fd = -1;
return PTY_GETPTY_SLAVE_TOOLONG;
}
- strcpy(slave, p);
return 0;
}
#include "com_err.h"
#include "libpty.h"
#include "pty-int.h"
+#include "k5-platform.h"
#if !defined(UTMP_FILE) && defined(_PATH_UTMP)
#define UTMP_FILE _PATH_UTMP
* pain, and would eit cross-compiling.
*/
#ifdef __hpux
- strcpy(utmp_id, cp);
+ strlcpy(utmp_id, cp, sizeof(utmp_id));
#else
if (len > 2 && *(cp - 1) != '/')
snprintf(utmp_id, sizeof(utmp_id), "k%s", cp - 1);
* the default is of length 4.
*/
if (krb5_princ_size(telnet_context,ticket->server) < 1) {
- (void) strcpy(errbuf, "malformed service name");
+ (void) strlcpy(errbuf, "malformed service name",
+ sizeof(errbuf));
goto errout;
}
if (krb5_princ_component(telnet_context,ticket->server,0)->length < 256) {
goto errout;
}
} else {
- (void) strcpy(errbuf, "service name too long");
+ (void) strlcpy(errbuf, "service name too long",
+ sizeof(errbuf));
goto errout;
}
}
if ((ap->way & AUTH_ENCRYPT_MASK) == AUTH_ENCRYPT_ON &&
!authenticator->checksum) {
- (void) strcpy(errbuf,
- "authenticator is missing required checksum");
+ (void) strlcpy(errbuf,
+ "authenticator is missing required checksum",
+ sizeof(errbuf));
goto errout;
}
if (authenticator->checksum) {
#include "fake-addrinfo.h"
+#include <k5-platform.h>
+
char *hostname;
static char _hostname[MAXDNAME];
static char hostaddrstring[NI_MAXHOST];
return 0;
}
if (argc < 2) {
- (void) strcpy(line, "open ");
+ (void) strlcpy(line, "open ", sizeof(line));
printf("(to) ");
(void) fgets(&line[strlen(line)], (int) (sizeof(line) - strlen(line)),
stdin);
if (error) {
fprintf (stderr, "getnameinfo() error printing address: %s\n",
gai_strerror (error));
- strcpy (hostaddrstring, "[address unprintable]");
+ strlcpy (hostaddrstring, "[address unprintable]",
+ sizeof(hostaddrstring));
}
printf("Trying %s...\r\n", hostaddrstring);
#if defined(IP_OPTIONS) && defined(IPPROTO_IP)
if (! principal->name[0])
return 0;
if (! principal->instance[0])
- strcpy(principal->instance, "*");
+ strlcpy(principal->instance, "*", sizeof(principal->instance));
/* Now move to mod princ */
if ((retval = krb5_dbe_lookup_mod_princ_data(util_context,entry,
}
if (! principal->mod_name[0])
- strcpy(principal->mod_name, "*");
+ strlcpy(principal->mod_name, "*", sizeof(principal->mod_name));
if (! principal->mod_instance[0])
- strcpy(principal->mod_instance, "*");
+ strlcpy(principal->mod_instance, "*", sizeof(principal->mod_instance));
/* OK deal with the key now. */
for (max_kvno = i = 0; i < entry->n_key_data; i++) {
/* XXX "!++s"? */
if (!++s)
return NULL;
- if (strlen(s) >= len)
+ if (strlcpy(cl, s, len) >= len)
return NULL;
- strcpy(cl, s);
/* XXX Copy with @REALM first, with bounds check, then
chop off the realm?? */
if ((s = strchr(cl, '@')) != NULL) {
or the caller passed in garbage */
ret = KRB5KRB_AP_ERR_MODIFIED;
numresult = KRB5_KPASSWD_MALFORMED;
- strcpy(strresult, "Request was truncated");
+ strlcpy(strresult, "Request was truncated", sizeof(strresult));
goto chpwfail;
}
if (ptr + ap_req.length >= req->data + req->length) {
ret = KRB5KRB_AP_ERR_MODIFIED;
numresult = KRB5_KPASSWD_MALFORMED;
- strcpy(strresult, "Request was truncated in AP-REQ");
+ strlcpy(strresult, "Request was truncated in AP-REQ",
+ sizeof(strresult));
goto chpwfail;
}
ret = krb5_auth_con_init(context, &auth_context);
if (ret) {
numresult = KRB5_KPASSWD_HARDERROR;
- strcpy(strresult, "Failed initializing auth context");
+ strlcpy(strresult, "Failed initializing auth context",
+ sizeof(strresult));
goto chpwfail;
}
KRB5_AUTH_CONTEXT_DO_SEQUENCE);
if (ret) {
numresult = KRB5_KPASSWD_HARDERROR;
- strcpy(strresult, "Failed initializing auth context");
+ strlcpy(strresult, "Failed initializing auth context",
+ sizeof(strresult));
goto chpwfail;
}
"kadmin", "changepw", NULL);
if (ret) {
numresult = KRB5_KPASSWD_HARDERROR;
- strcpy(strresult, "Failed building kadmin/changepw principal");
+ strlcpy(strresult, "Failed building kadmin/changepw principal",
+ sizeof(strresult));
goto chpwfail;
}
if (ret) {
numresult = KRB5_KPASSWD_AUTHERROR;
- strcpy(strresult, "Failed reading application request");
+ strlcpy(strresult, "Failed reading application request",
+ sizeof(strresult));
goto chpwfail;
}
if (getsockname(s, &local_addr, &addrlen) < 0) {
ret = errno;
numresult = KRB5_KPASSWD_HARDERROR;
- strcpy(strresult, "Failed getting server internet address");
+ strlcpy(strresult, "Failed getting server internet address",
+ sizeof(strresult));
goto chpwfail;
}
if (getpeername(s, &remote_addr, &addrlen) < 0) {
ret = errno;
numresult = KRB5_KPASSWD_HARDERROR;
- strcpy(strresult, "Failed getting client internet address");
+ strlcpy(strresult, "Failed getting client internet address",
+ sizeof(strresult));
goto chpwfail;
}
&remote_kaddr);
if (ret) {
numresult = KRB5_KPASSWD_HARDERROR;
- strcpy(strresult, "Failed storing client internet address");
+ strlcpy(strresult, "Failed storing client internet address",
+ sizeof(strresult));
goto chpwfail;
}
if (!(ticket->enc_part2->flags & TKT_FLG_INITIAL)) {
numresult = KRB5_KPASSWD_AUTHERROR;
- strcpy(strresult, "Ticket must be derived from a password");
+ strlcpy(strresult, "Ticket must be derived from a password",
+ sizeof(strresult));
goto chpwfail;
}
ret = krb5_mk_rep(context, auth_context, &ap_rep);
if (ret) {
numresult = KRB5_KPASSWD_AUTHERROR;
- strcpy(strresult, "Failed replying to application request");
+ strlcpy(strresult, "Failed replying to application request",
+ sizeof(strresult));
goto chpwfail;
}
ret = krb5_rd_priv(context, auth_context, &cipher, &clear, &replay);
if (ret) {
numresult = KRB5_KPASSWD_HARDERROR;
- strcpy(strresult, "Failed decrypting request");
+ strlcpy(strresult, "Failed decrypting request", sizeof(strresult));
goto chpwfail;
}
ret = krb5_unparse_name(context, ticket->enc_part2->client, &clientstr);
if (ret) {
numresult = KRB5_KPASSWD_HARDERROR;
- strcpy(strresult, "Failed unparsing client name for log");
+ strlcpy(strresult, "Failed unparsing client name for log",
+ sizeof(strresult));
goto chpwfail;
}
/* change the password */
/* success! */
numresult = KRB5_KPASSWD_SUCCESS;
- strcpy(strresult, "");
+ strlcpy(strresult, "", sizeof(strresult));
chpwfail:
NULL);
if (ret) {
numresult = KRB5_KPASSWD_HARDERROR;
- strcpy(strresult,
- "Failed storing client and server internet addresses");
+ strlcpy(strresult,
+ "Failed storing client and server internet addresses",
+ sizeof(strresult));
} else {
ret = krb5_mk_priv(context, auth_context, &clear, &cipher,
&replay);
if (ret) {
numresult = KRB5_KPASSWD_HARDERROR;
- strcpy(strresult, "Failed encrypting reply");
+ strlcpy(strresult, "Failed encrypting reply",
+ sizeof(strresult));
}
}
}
#include <com_err.h>
#include <kerberosIV/krb.h>
#include <kerberosIV/des.h>
+#include <k5-platform.h>
#ifndef LINT
static char rcsid[]=
* Initialize these so we don't crash trying to print them in
* case they don't get filled in.
*/
- strcpy(rname, "Unknown");
- strcpy(rinst, "Unknown");
- strcpy(sname, "Unknown");
- strcpy(sinst, "Unknown");
- strcpy(cname, "Unknown");
- strcpy(cinst, "Unknown");
- strcpy(cell, "Unknown");
- strcpy(realm, "Unknown");
+ strlcpy(rname, "Unknown", sizeof(rname));
+ strlcpy(rinst, "Unknown", sizeof(rinst));
+ strlcpy(sname, "Unknown", sizeof(sname));
+ strlcpy(sinst, "Unknown", sizeof(sinst));
+ strlcpy(cname, "Unknown", sizeof(cname));
+ strlcpy(cinst, "Unknown", sizeof(cinst));
+ strlcpy(cell, "Unknown", sizeof(cell));
+ strlcpy(realm, "Unknown", sizeof(realm));
p = req->base;
maxn = req->len;
GET_PSTR(cell);
if (!cell[0])
- strcpy(cell, localcell);
+ strlcpy(cell, localcell, sizeof(cell));
if (debug)
fprintf(stderr, "Cell is %s\n", cell);
(strcasecmp(cell, localcell) == 0)) {
char *c;
- strcpy(rinst, localcell);
+ strlcpy(rinst, localcell, sizeof(rinst));
for (c = rinst; *c != NULL; c++)
*c = (char) tolower( (int) *c);
free(a);
return ENOMEM;
}
- strcpy(p, "hello");
+ strlcpy(p, "hello", GREET_SIZE);
a->magic = KV5M_AUTHDATA;
a->ad_type = -42;
a->length = GREET_SIZE;
case L_NTGT_INTK:
case L_TKT_REQ:
case L_APPL_REQ:
- strcpy(log_text, "PROCESS_V4:");
+ strlcpy(log_text, "PROCESS_V4:", sizeof(log_text));
vsnprintf(log_text+strlen(log_text),
sizeof(log_text) - strlen(log_text),
format, pvar);
if (getnameinfo(sa, socklen(sa),
buf, sizeof(buf), portbuf, sizeof(portbuf),
NI_NUMERICHOST|NI_NUMERICSERV))
- strcpy(buf, "<unprintable>");
+ strlcpy(buf, "<unprintable>", sizeof(buf));
else {
unsigned int len = sizeof(buf) - strlen(buf);
char *p = buf + strlen(buf);
err = getnameinfo(addr, socklen(addr), haddrbuf, sizeof(haddrbuf),
0, 0, NI_NUMERICHOST);
if (err)
- strcpy(haddrbuf, "<unprintable>");
+ strlcpy(haddrbuf, "<unprintable>", sizeof(haddrbuf));
switch (addr->sa_family) {
case AF_INET:
char addrbuf[100];
if (getnameinfo(ss2sa(&daddr), daddr_len, addrbuf, sizeof(addrbuf),
0, 0, NI_NUMERICHOST))
- strcpy(addrbuf, "?");
+ strlcpy(addrbuf, "?", sizeof(addrbuf));
com_err(prog, 0, "pktinfo says local addr is %s", addrbuf);
}
#endif
krb5_free_data(kdc_context, response);
if (inet_ntop(((struct sockaddr *)&saddr)->sa_family,
addr.contents, addrbuf, sizeof(addrbuf)) == 0) {
- strcpy(addrbuf, "?");
+ strlcpy(addrbuf, "?", sizeof(addrbuf));
}
com_err(prog, errno, "while sending reply to %s/%d",
addrbuf, faddr.port);
newconn->u.tcp.addrbuf, sizeof(newconn->u.tcp.addrbuf),
tmpbuf, sizeof(tmpbuf),
NI_NUMERICHOST | NI_NUMERICSERV))
- strcpy(newconn->u.tcp.addrbuf, "???");
+ strlcpy(newconn->u.tcp.addrbuf, "???", sizeof(newconn->u.tcp.addrbuf));
else {
char *p, *end;
p = newconn->u.tcp.addrbuf;
p += strlen(p);
if (end - p > 2 + strlen(tmpbuf)) {
*p++ = '.';
- strcpy(p, tmpbuf);
+ strlcpy(p, tmpbuf, end - p);
}
}
#if 0
for (i=0; i<krb5_cksumtypes_length; i++) {
if (krb5_cksumtypes_list[i].ctype == cksumtype) {
- if ((strlen(krb5_cksumtypes_list[i].out_string)+1) > buflen)
+ if (strlcpy(buffer, krb5_cksumtypes_list[i].out_string,
+ buflen) >= buflen)
return(ENOMEM);
-
- strcpy(buffer, krb5_cksumtypes_list[i].out_string);
return(0);
}
}
for (i=0; i<krb5_enctypes_length; i++) {
if (krb5_enctypes_list[i].etype == enctype) {
- if ((strlen(krb5_enctypes_list[i].out_string)+1) > buflen)
+ if (strlcpy(buffer, krb5_enctypes_list[i].out_string,
+ buflen) >= buflen)
return(ENOMEM);
-
- strcpy(buffer, krb5_enctypes_list[i].out_string);
return(0);
}
}
$(TOPLIBD)/libgssapi_krb5$(SHLIBEXT) \
$(TOPLIBD)/libkrb5$(SHLIBEXT) \
$(TOPLIBD)/libk5crypto$(SHLIBEXT) \
- $(COM_ERR_DEPLIB)
-SHLIB_EXPLIBS=-lgssrpc -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err
+ $(COM_ERR_DEPLIB) $(SUPPORT_LIBDEP)
+SHLIB_EXPLIBS=-lgssrpc -lgssapi_krb5 -lkrb5 -lk5crypto $(SUPPORT_LIB) -lcom_err
SHLIB_DIRS=-L$(TOPLIBD)
SHLIB_RDIRS=$(KRB5_LIBDIR)
RELDIR=kadm5/clnt
$(TOPLIBD)/libkdb5$(SHLIBEXT) \
$(TOPLIBD)/libkrb5$(SHLIBEXT) \
$(TOPLIBD)/libk5crypto$(SHLIBEXT) \
- $(COM_ERR_DEPLIB)
+ $(COM_ERR_DEPLIB) $(SUPPORT_LIBDEP)
SHLIB_EXPLIBS = -lgssrpc -lgssapi_krb5 -lkdb5 $(KDB5_DB_LIB) \
- -lkrb5 -lk5crypto -lcom_err @GEN_LIB@
+ -lkrb5 -lk5crypto $(SUPPORT_LIB) -lcom_err @GEN_LIB@
SHLIB_DIRS=-L$(TOPLIBD)
SHLIB_RDIRS=$(KRB5_LIBDIR)
RELDIR=kadm5/srv
size_t buflen;
{
if(flag < 0 || flag >= flags_table_nents) return ENOENT; /* End of list */
- if(strlen(flags_table[flag].fl_specifier) > buflen) return ENOMEM;
- strcpy(buffer, flags_table[flag].fl_specifier);
+ if(strlcpy(buffer, flags_table[flag].fl_specifier, buflen) >= buflen)
+ return ENOMEM;
return 0;
}
goto clean_n_exit;
}
- strcpy((*lib)->name, lib_name);
+ strlcpy((*lib)->name, lib_name, sizeof((*lib)->name));
#if !defined(KDB5_USE_LIB_KDB_DB2) && !defined(KDB5_USE_LIB_TEST)
#error No database module defined
goto clean_n_exit;
}
- strcpy((*lib)->name, lib_name);
+ strlcpy((*lib)->name, lib_name, sizeof((*lib)->name));
/* Fetch the list of directories specified in the config
file(s) first. */
krb5_ktkdb_get_name(krb5_context context, krb5_keytab keytab,
char *name, unsigned int namelen)
{
- if (namelen < sizeof("KDB:"))
+ if (strlcpy(name, "KDB:", namelen) >= namelen);
return KRB5_KT_NAME_TOOLONG;
- strcpy(name, "KDB:");
return 0;
}
* It is, so set the new name now, and chop off
* instance's domain name if requested.
*/
- if (strlen (p->v4_str) > ANAME_SZ - 1)
+ if (strlcpy(name, p->v4_str, ANAME_SZ) >= ANAME_SZ)
return KRB5_INVALID_PRINCIPAL;
- strcpy(name, p->v4_str);
if (p->flags & DO_REALM_CONVERSION) {
compo = krb5_princ_component(context, princ, 1);
c = strnchr(compo->data, '.', compo->length);
pw0.data = pw0array;
if (password && password[0]) {
- if ((pw0.length = strlen(password)) > sizeof(pw0array)) {
- ret = EINVAL;
- goto cleanup;
+ if (strlcpy(pw0.data, password, sizeof(pw0array)) >= sizeof(pw0array)) {
+ ret = EINVAL;
+ goto cleanup;
}
- strcpy(pw0.data, password);
+ pw0.length = strlen(password);
} else {
pw0.data[0] = '\0';
pw0.length = sizeof(pw0array);
prompt[1].reply = &pw1;
prompt_types[1] = KRB5_PROMPT_TYPE_NEW_PASSWORD_AGAIN;
- strcpy(banner, "Password expired. You must change it now.");
+ strlcpy(banner, "Password expired. You must change it now.",
+ sizeof(banner));
for (tries = 3; tries; tries--) {
pw0.length = sizeof(pw0array);
}
}
if (out) {
- if (buflen > strlen(out))
- strcpy(buffer, out);
- else
- out = (char *) NULL;
- return((out) ? 0 : ENOMEM);
+ if (strlcpy(buffer, out, buflen) >= buflen)
+ return(ENOMEM);
+ return(0);
}
else
return(EINVAL);
kret = aname_replacer(selstring, ¤t, &outstring);
if (outstring) {
/* Copy out the value if there's enough room */
- if (strlen(outstring)+1 <= (size_t) lnsize)
- strcpy(lname, outstring);
- else
+ if (strlcpy(lname, outstring, lnsize) >= lnsize)
kret = KRB5_CONFIG_NOTENUFSPACE;
free(outstring);
}
}
/* Copy out the value if there's enough room */
- if (strlen(mapping_values[nvalid-1])+1 <= (size_t) lnsize)
- strcpy(lname, mapping_values[nvalid-1]);
- else
+ if (strlcpy(lname, mapping_values[nvalid-1],
+ lnsize) >= lnsize)
kret = KRB5_CONFIG_NOTENUFSPACE;
/* Free residue */
*/
if (name == NULL || name[0] == '\0') {
- if (strlen (prefix) >= sizeof(host)-1)
+ if (strlcpy(host, prefix, sizeof(host)) >= sizeof(host))
return KRB5_ERR_HOST_REALM_UNKNOWN;
- strcpy(host,prefix);
} else {
if ( strlen(prefix) + strlen(name) + 3 > MAXDNAME )
return KRB5_ERR_HOST_REALM_UNKNOWN;
unsigned int namesize = (name_size < 0 ? 0 : name_size);
if (krb5_overridekeyname) {
- if (namesize < (strlen(krb5_overridekeyname)+1))
+ if (strlcpy(name, krb5_overridekeyname, namesize) >= namesize)
return KRB5_CONFIG_NOTENUFSPACE;
- strcpy(name, krb5_overridekeyname);
} else if ((context->profile_secure == FALSE) &&
(cp = getenv("KRB5_KTNAME"))) {
- if (namesize < (strlen(cp)+1))
+ if (strlcpy(name, cp, namesize) >= namesize)
return KRB5_CONFIG_NOTENUFSPACE;
- strcpy(name, cp);
} else if ((profile_get_string(context->profile,
"libdefaults",
"default_keytab_name", NULL,
NULL, &retval) == 0) &&
retval) {
- if (namesize < (strlen(retval)+1))
+ if (strlcpy(name, retval, namesize) >= namesize)
return KRB5_CONFIG_NOTENUFSPACE;
- strcpy(name, retval);
profile_release_string(retval);
} else {
#if defined(_WIN32)
snprintf(name, namesize, krb5_defkeyname, defname);
}
#else
- if (namesize < (strlen(krb5_defkeyname)+1))
+ if (strlcpy(name, krb5_defkeyname, namesize) >= namesize)
return KRB5_CONFIG_NOTENUFSPACE;
- strcpy(name, krb5_defkeyname);
#endif
}
return 0;
/* %A => addrinfo */
ai = va_arg(args, struct addrinfo *);
if (ai->ai_socktype == SOCK_DGRAM)
- strcpy(tmpbuf, "dgram");
+ strlcpy(tmpbuf, "dgram", sizeof(tmpbuf));
else if (ai->ai_socktype == SOCK_STREAM)
- strcpy(tmpbuf, "stream");
+ strlcpy(tmpbuf, "stream", sizeof(tmpbuf));
else
snprintf(tmpbuf, sizeof(tmpbuf), "socktype%d", ai->ai_socktype);
if (0 != getnameinfo (ai->ai_addr, ai->ai_addrlen,
retval = errno;
goto errout;
}
- strcat(new_policy, ".lock");
+ strlcat(new_policy, ".lock",sizeof(new_policy));
(void) unlink(new_policy);
}
$(CC_LINK) -o $@ resolve.o $(LIBS)
addrinfo-test: addrinfo-test.o
- $(CC_LINK) -o $@ addrinfo-test.o $(LIBS)
+ $(CC_LINK) -o $@ addrinfo-test.o $(SUPPORT_LIB) $(LIBS)
fake-addrinfo-test: fake-addrinfo-test.o
$(CC_LINK) -o $@ fake-addrinfo-test.o $(SUPPORT_LIB) $(LIBS)
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h> /* needed for IPPROTO_* on NetBSD */
+#include <k5-platform.h>
#ifdef USE_FAKE_ADDRINFO
#include "fake-addrinfo.h"
#endif
ap2->ai_addr->sa_family = ap2->ai_family;
}
if (getnameinfo(ap2->ai_addr, ap2->ai_addrlen, hbuf, sizeof(hbuf),
- pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV))
- strcpy(hbuf, "..."), strcpy(pbuf, "...");
+ pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV)) {
+ strlcpy(hbuf, "...", sizeof(hbuf));
+ strlcpy(pbuf, "...", sizeof(pbuf));
+ }
printf("%p:\n"
"\tfamily = %s\tproto = %-4s\tsocktype = %s\n",
ap2, familyname(ap2->ai_family),
if (cp == NULL)
return "Unknown error code";
cp1 = cp;
- strcpy(cp, "Unknown code ");
+ strlcpy(cp, "Unknown code ", ET_EBUFSIZ);
cp += sizeof("Unknown code ") - 1;
if (table_num != 0L) {
(void) error_table_name_r(table_num, cp);
if (code == ep->code && ep->msg) {
r = strdup(ep->msg);
if (r == NULL) {
- strcpy(ep->scratch_buf, _("Out of memory"));
+ strlcpy(ep->scratch_buf, _("Out of memory"),
+ sizeof(ep->scratch_buf));
r = ep->scratch_buf;
}
return r;