merge strcpy_truncate branch
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@5027 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -58,7 +58,7 @@ afs_verify(char *name,
|
||||
int quiet)
|
||||
{
|
||||
int ret = 1;
|
||||
char lrealm[REALM_SZ + 1];
|
||||
char lrealm[REALM_SZ];
|
||||
char tkt_string[MaxPathLen];
|
||||
struct passwd *pwd;
|
||||
|
||||
|
@@ -150,10 +150,10 @@ auth_su(pam_handle_t *pamh, int flags, char *user, struct pam_conv *conv)
|
||||
|
||||
pw = getpwuid(getuid());
|
||||
if(strcmp(user, "root") == 0){
|
||||
strcpy(pr.name, pw->pw_name);
|
||||
strcpy(pr.instance, "root");
|
||||
strcpy_truncate(pr.name, pw->pw_name, sizeof(pr.name));
|
||||
strcpy_truncate(pr.instance, "root", sizeof(pr.instance));
|
||||
}else{
|
||||
strcpy(pr.name, user);
|
||||
strcpy_truncate(pr.name, user, sizeof(pr.name));
|
||||
pr.instance[0] = 0;
|
||||
}
|
||||
pmsg = &msg;
|
||||
|
@@ -363,8 +363,12 @@ siad_ses_suauthent(sia_collect_func_t *collect,
|
||||
return SIADFAIL;
|
||||
if(entity->name == NULL)
|
||||
return SIADFAIL;
|
||||
if(entity->name[0] == 0)
|
||||
strcpy(entity->name, "root");
|
||||
if(entity->name[0] == 0) {
|
||||
free(entity->name);
|
||||
entity->name = strdup("root");
|
||||
if (entity->name == NULL)
|
||||
return SIADFAIL;
|
||||
}
|
||||
return common_auth(collect, entity, siastat, pkgind);
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997 Kungliga Tekniska H<>gskolan
|
||||
* Copyright (c) 1997, 1998 Kungliga Tekniska H<>gskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -43,6 +43,7 @@ RCSID("$Id$");
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <roken.h>
|
||||
#include "com_err.h"
|
||||
|
||||
struct et_list *_et_list;
|
||||
@@ -53,8 +54,7 @@ error_message (long code)
|
||||
static char msg[128];
|
||||
const char *p = com_right(_et_list, code);
|
||||
if(p){
|
||||
strncpy(msg, p, sizeof(msg));
|
||||
msg[sizeof(msg)-1] = '\0';
|
||||
strcpy_truncate(msg, p, sizeof(msg));
|
||||
} else{
|
||||
snprintf(msg, sizeof(msg), "Unknown error %d", code);
|
||||
}
|
||||
@@ -76,18 +76,18 @@ default_proc (const char *whoami, long code, const char *fmt, va_list args)
|
||||
const void *arg[3], **ap = arg;
|
||||
|
||||
if(whoami) {
|
||||
strcat(f, "%s: ");
|
||||
strcat_truncate(f, "%s: ", sizeof(f));
|
||||
*ap++ = whoami;
|
||||
}
|
||||
if(code) {
|
||||
strcat(f, "%s ");
|
||||
strcat_truncate(f, "%s ", sizeof(f));
|
||||
*ap++ = error_message(code);
|
||||
}
|
||||
if(fmt) {
|
||||
strcat(f, "%s");
|
||||
strcat_truncate(f, "%s", sizeof(f));
|
||||
*ap++ = fmt;
|
||||
}
|
||||
strcat(f, "\r\n");
|
||||
strcat_truncate(f, "\r\n", sizeof(f));
|
||||
asprintf(&x, f, arg[0], arg[1], arg[2]);
|
||||
vfprintf(stderr, x, args);
|
||||
free(x);
|
||||
|
@@ -203,9 +203,8 @@ crypt_md5(pw, salt)
|
||||
MD5Update(&ctx, pw+j, 1);
|
||||
|
||||
/* Now make the output string */
|
||||
strcpy(passwd,magic);
|
||||
strncat(passwd,sp,sl);
|
||||
strcat(passwd,"$");
|
||||
snprintf (passwd, sizeof(passwd),
|
||||
"%s%.*s$", magic, sl, sp);
|
||||
|
||||
MD5Final(final,&ctx);
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 1996, 1997 Kungliga Tekniska H<>gskolan
|
||||
* Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska H<>gskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -84,12 +84,12 @@ pwd_dialog(char *buf, int size)
|
||||
switch(DialogBox(hInst,MAKEINTRESOURCE(IDD_PASSWD_DIALOG),wnd,pwd_dialog_proc))
|
||||
{
|
||||
case IDOK:
|
||||
strcpy(buf,passwd);
|
||||
for(i=0; passwd[i] != '\0'; i++) passwd[i] = '\0';
|
||||
strcpy_truncate(buf, passwd, size);
|
||||
memset (passwd, 0, sizeof(passwd));
|
||||
return 0;
|
||||
case IDCANCEL:
|
||||
default:
|
||||
for(i=0; passwd[i] != '\0'; i++) passwd[i] = '\0';
|
||||
memset (passwd, 0, sizeof(passwd));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@@ -10,3 +10,10 @@ Sun Apr 19 09:53:46 1998 Assar Westerlund <assar@sics.se>
|
||||
|
||||
* Makefile.in: add symlink magic for linux
|
||||
|
||||
Sat Feb 7 07:24:30 1998 Assar Westerlund <assar@sics.se>
|
||||
|
||||
* editline.h: add prototypes
|
||||
|
||||
Tue Feb 3 10:24:22 1998 Johan Danielsson <joda@emma.pdc.kth.se>
|
||||
|
||||
* editline.c: If read returns EINTR, try again.
|
||||
|
@@ -169,9 +169,8 @@ rl_complete(pathname, unique)
|
||||
if ((p = NEW(char, j + 1)) != NULL) {
|
||||
COPYFROMTO(p, av[0] + len, j);
|
||||
if ((new = NEW(char, strlen(dir) + strlen(av[0]) + 2)) != NULL) {
|
||||
(void)strcpy(new, dir);
|
||||
(void)strcat(new, "/");
|
||||
(void)strcat(new, av[0]);
|
||||
snprintf (new, sizeof(new),
|
||||
"%s/%s", dir, av[0]);
|
||||
rl_add_slash(new, p);
|
||||
DISPOSE(new);
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include <config.h>
|
||||
#include "editline.h"
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
RCSID("$Id$");
|
||||
|
||||
@@ -177,10 +178,11 @@ TTYstring(unsigned char *p)
|
||||
TTYshow(*p++);
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
static int
|
||||
TTYget()
|
||||
{
|
||||
unsigned char c;
|
||||
char c;
|
||||
int e;
|
||||
|
||||
TTYflush();
|
||||
if (Pushed) {
|
||||
@@ -189,7 +191,12 @@ TTYget()
|
||||
}
|
||||
if (*Input)
|
||||
return *Input++;
|
||||
return read(0, &c, (size_t)1) == 1 ? c : EOF;
|
||||
do {
|
||||
e = read(0, &c, 1);
|
||||
} while(e < 0 && errno == EINTR);
|
||||
if(e == 1)
|
||||
return c;
|
||||
return EOF;
|
||||
}
|
||||
|
||||
#define TTYback() (backspace ? TTYputs((unsigned char *)backspace) : TTYput('\b'))
|
||||
|
@@ -53,7 +53,7 @@ extern int rl_erase;
|
||||
extern int rl_intr;
|
||||
extern int rl_kill;
|
||||
extern int rl_quit;
|
||||
extern char *rl_complete();
|
||||
extern int rl_list_possib();
|
||||
extern void rl_ttyset();
|
||||
extern void rl_add_slash();
|
||||
extern char *rl_complete(char *, int *);
|
||||
extern int rl_list_possib(char *, char ***);
|
||||
extern void rl_ttyset(int);
|
||||
extern void rl_add_slash(char *, char *);
|
||||
|
@@ -26,6 +26,14 @@ Thu Feb 12 11:20:15 1998 Johan Danielsson <joda@emma.pdc.kth.se>
|
||||
|
||||
* Makefile.in: Install/uninstall one library at a time.
|
||||
|
||||
Thu Feb 12 05:38:58 1998 Assar Westerlund <assar@sics.se>
|
||||
|
||||
* Makefile.in (install): one library at a time.
|
||||
|
||||
Mon Feb 9 23:40:32 1998 Assar Westerlund <assar@sics.se>
|
||||
|
||||
* common.c (find_cells): ignore empty lines
|
||||
|
||||
Tue Jan 6 04:25:58 1998 Assar Westerlund <assar@sics.se>
|
||||
|
||||
* afssysdefs.h (AFS_SYSCALL): add FreeBSD
|
||||
|
@@ -87,9 +87,10 @@ static char *
|
||||
get_realm(kafs_data *data, const char *host)
|
||||
{
|
||||
char *r = krb_realmofhost(host);
|
||||
if(r)
|
||||
if(r != NULL)
|
||||
return strdup(r);
|
||||
return NULL;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -97,6 +98,7 @@ krb_afslog_uid(const char *cell, const char *realm, uid_t uid)
|
||||
{
|
||||
kafs_data kd;
|
||||
struct krb_kafs_data d;
|
||||
|
||||
kd.afslog_uid = afslog_uid_int;
|
||||
kd.get_cred = get_cred;
|
||||
kd.get_realm = get_realm;
|
||||
|
@@ -63,7 +63,7 @@ aix_setup(void)
|
||||
* If we are root or running setuid don't trust AFSLIBPATH!
|
||||
*/
|
||||
if (getuid() != 0 && !issuid() && (p = getenv("AFSLIBPATH")) != NULL)
|
||||
snprintf(path, sizeof(path), "%s", p);
|
||||
strcpy_truncate(path, p, sizeof(path));
|
||||
else
|
||||
snprintf(path, sizeof(path), "%s/afslib.so", LIBDIR);
|
||||
|
||||
|
@@ -79,7 +79,7 @@
|
||||
#define AFS_SYSCALL 31
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__)
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#define AFS_SYSCALL 210
|
||||
#endif
|
||||
|
||||
|
@@ -155,8 +155,9 @@ dns_find_cell(const char *cell, char *dbserver, size_t len)
|
||||
struct resource_record *rr = r->head;
|
||||
while(rr){
|
||||
if(rr->type == T_AFSDB && rr->u.afsdb->preference == 1){
|
||||
strncpy(dbserver, rr->u.afsdb->domain, len);
|
||||
dbserver[len - 1] = '\0';
|
||||
strcpy_truncate(dbserver,
|
||||
rr->u.afsdb->domain,
|
||||
len);
|
||||
ok = 0;
|
||||
break;
|
||||
}
|
||||
@@ -184,7 +185,10 @@ find_cells(char *file, char ***cells, int *index)
|
||||
return;
|
||||
while (fgets(cell, sizeof(cell), f)) {
|
||||
char *nl = strchr(cell, '\n');
|
||||
if (nl) *nl = 0;
|
||||
if (nl)
|
||||
*nl = '\0';
|
||||
if (cell[0] == '\0')
|
||||
continue;
|
||||
for(i = 0; i < ind; i++)
|
||||
if(strcmp((*cells)[i], cell) == 0)
|
||||
break;
|
||||
|
119
lib/kafs/dlfcn.c
119
lib/kafs/dlfcn.c
@@ -115,14 +115,12 @@ void *dlopen(const char *path, int mode)
|
||||
}
|
||||
if ((mp = (ModulePtr)calloc(1, sizeof(*mp))) == NULL) {
|
||||
errvalid++;
|
||||
strcpy(errbuf, "calloc: ");
|
||||
strcat(errbuf, strerror(errno));
|
||||
snprintf (errbuf, "calloc: %s", strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
if ((mp->name = strdup(path)) == NULL) {
|
||||
errvalid++;
|
||||
strcpy(errbuf, "strdup: ");
|
||||
strcat(errbuf, strerror(errno));
|
||||
snprintf (errbuf, "strdup: %s", strerror(errno));
|
||||
free(mp);
|
||||
return NULL;
|
||||
}
|
||||
@@ -134,9 +132,8 @@ void *dlopen(const char *path, int mode)
|
||||
free(mp->name);
|
||||
free(mp);
|
||||
errvalid++;
|
||||
strcpy(errbuf, "dlopen: ");
|
||||
strcat(errbuf, path);
|
||||
strcat(errbuf, ": ");
|
||||
snprintf (errbuf, sizeof(errbuf),
|
||||
"dlopen: %s: ", path);
|
||||
/*
|
||||
* If AIX says the file is not executable, the error
|
||||
* can be further described by querying the loader about
|
||||
@@ -145,14 +142,18 @@ void *dlopen(const char *path, int mode)
|
||||
if (errno == ENOEXEC) {
|
||||
char *tmp[BUFSIZ/sizeof(char *)];
|
||||
if (loadquery(L_GETMESSAGES, tmp, sizeof(tmp)) == -1)
|
||||
strcpy(errbuf, strerror(errno));
|
||||
strcpy_truncate(errbuf,
|
||||
strerror(errno),
|
||||
sizeof(errbuf));
|
||||
else {
|
||||
char **p;
|
||||
for (p = tmp; *p; p++)
|
||||
caterr(*p);
|
||||
}
|
||||
} else
|
||||
strcat(errbuf, strerror(errno));
|
||||
strcat_truncate(errbuf,
|
||||
strerror(errno),
|
||||
sizeof(errbuf));
|
||||
return NULL;
|
||||
}
|
||||
mp->refCnt = 1;
|
||||
@@ -161,8 +162,8 @@ void *dlopen(const char *path, int mode)
|
||||
if (loadbind(0, mainModule, mp->entry) == -1) {
|
||||
dlclose(mp);
|
||||
errvalid++;
|
||||
strcpy(errbuf, "loadbind: ");
|
||||
strcat(errbuf, strerror(errno));
|
||||
snprintf (errbuf, sizeof(errbuf),
|
||||
"loadbind: %s", strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
/*
|
||||
@@ -175,8 +176,9 @@ void *dlopen(const char *path, int mode)
|
||||
if (loadbind(0, mp1->entry, mp->entry) == -1) {
|
||||
dlclose(mp);
|
||||
errvalid++;
|
||||
strcpy(errbuf, "loadbind: ");
|
||||
strcat(errbuf, strerror(errno));
|
||||
snprintf (errbuf, sizeof(errbuf),
|
||||
"loadbind: %s",
|
||||
strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -229,29 +231,29 @@ static void caterr(char *s)
|
||||
p++;
|
||||
switch(atoi(s)) {
|
||||
case L_ERROR_TOOMANY:
|
||||
strcat(errbuf, "to many errors");
|
||||
strcat_truncate(errbuf, "to many errors", sizeof(errbuf));
|
||||
break;
|
||||
case L_ERROR_NOLIB:
|
||||
strcat(errbuf, "can't load library");
|
||||
strcat(errbuf, p);
|
||||
strcat_truncate(errbuf, "can't load library", sizeof(errbuf));
|
||||
strcat_truncate(errbuf, p, sizeof(errbuf));
|
||||
break;
|
||||
case L_ERROR_UNDEF:
|
||||
strcat(errbuf, "can't find symbol");
|
||||
strcat(errbuf, p);
|
||||
strcat_truncate(errbuf, "can't find symbol", sizeof(errbuf));
|
||||
strcat_truncate(errbuf, p, sizeof(errbuf));
|
||||
break;
|
||||
case L_ERROR_RLDBAD:
|
||||
strcat(errbuf, "bad RLD");
|
||||
strcat(errbuf, p);
|
||||
strcat_truncate(errbuf, "bad RLD", sizeof(errbuf));
|
||||
strcat_truncate(errbuf, p, sizeof(errbuf));
|
||||
break;
|
||||
case L_ERROR_FORMAT:
|
||||
strcat(errbuf, "bad exec format in");
|
||||
strcat(errbuf, p);
|
||||
strcat_truncate(errbuf, "bad exec format in", sizeof(errbuf));
|
||||
strcat_truncate(errbuf, p, sizeof(errbuf));
|
||||
break;
|
||||
case L_ERROR_ERRNO:
|
||||
strcat(errbuf, strerror(atoi(++p)));
|
||||
strcat_truncate(errbuf, strerror(atoi(++p)), sizeof(errbuf));
|
||||
break;
|
||||
default:
|
||||
strcat(errbuf, s);
|
||||
strcat_truncate(errbuf, s, sizeof(errbuf));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -270,8 +272,8 @@ void *dlsym(void *handle, const char *symbol)
|
||||
if (strcmp(ep->name, symbol) == 0)
|
||||
return ep->addr;
|
||||
errvalid++;
|
||||
strcpy(errbuf, "dlsym: undefined symbol ");
|
||||
strcat(errbuf, symbol);
|
||||
snprintf (errbuf, sizeof(errbuf),
|
||||
"dlsym: undefined symbol %s", symbol);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -311,7 +313,8 @@ int dlclose(void *handle)
|
||||
result = unload(mp->entry);
|
||||
if (result == -1) {
|
||||
errvalid++;
|
||||
strcpy(errbuf, strerror(errno));
|
||||
snprintf (errbuf, sizeof(errbuf),
|
||||
"%s", strerror(errno));
|
||||
}
|
||||
if (mp->exports) {
|
||||
ExportPtr ep;
|
||||
@@ -360,8 +363,9 @@ static int readExports(ModulePtr mp)
|
||||
int size = 4*1024;
|
||||
if (errno != ENOENT) {
|
||||
errvalid++;
|
||||
strcpy(errbuf, "readExports: ");
|
||||
strcat(errbuf, strerror(errno));
|
||||
snprintf(errbuf, sizeof(errbuf),
|
||||
"readExports: %s",
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
/*
|
||||
@@ -371,8 +375,9 @@ static int readExports(ModulePtr mp)
|
||||
*/
|
||||
if ((buf = malloc(size)) == NULL) {
|
||||
errvalid++;
|
||||
strcpy(errbuf, "readExports: ");
|
||||
strcat(errbuf, strerror(errno));
|
||||
snprintf(errbuf, sizeof(errbuf),
|
||||
"readExports: %s",
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
while ((i = loadquery(L_GETINFO, buf, size)) == -1 && errno == ENOMEM) {
|
||||
@@ -380,15 +385,17 @@ static int readExports(ModulePtr mp)
|
||||
size += 4*1024;
|
||||
if ((buf = malloc(size)) == NULL) {
|
||||
errvalid++;
|
||||
strcpy(errbuf, "readExports: ");
|
||||
strcat(errbuf, strerror(errno));
|
||||
snprintf(errbuf, sizeof(errbuf),
|
||||
"readExports: %s",
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (i == -1) {
|
||||
errvalid++;
|
||||
strcpy(errbuf, "readExports: ");
|
||||
strcat(errbuf, strerror(errno));
|
||||
snprintf(errbuf, sizeof(errbuf),
|
||||
"readExports: %s",
|
||||
strerror(errno));
|
||||
free(buf);
|
||||
return -1;
|
||||
}
|
||||
@@ -411,14 +418,14 @@ static int readExports(ModulePtr mp)
|
||||
free(buf);
|
||||
if (!ldp) {
|
||||
errvalid++;
|
||||
strcpy(errbuf, "readExports: ");
|
||||
strcat(errbuf, strerror(errno));
|
||||
snprintf (errbuf, sizeof(errbuf),
|
||||
"readExports: %s", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (TYPE(ldp) != U802TOCMAGIC) {
|
||||
errvalid++;
|
||||
strcpy(errbuf, "readExports: bad magic");
|
||||
snprintf(errbuf, sizeof(errbuf), "readExports: bad magic");
|
||||
while(ldclose(ldp) == FAILURE)
|
||||
;
|
||||
return -1;
|
||||
@@ -430,14 +437,16 @@ static int readExports(ModulePtr mp)
|
||||
*/
|
||||
if (ldnshread(ldp, _DATA, &shdata) != SUCCESS) {
|
||||
errvalid++;
|
||||
strcpy(errbuf, "readExports: cannot read data section header");
|
||||
snprintf(errbuf, sizeof(errbuf),
|
||||
"readExports: cannot read data section header");
|
||||
while(ldclose(ldp) == FAILURE)
|
||||
;
|
||||
return -1;
|
||||
}
|
||||
if (ldnshread(ldp, _LOADER, &sh) != SUCCESS) {
|
||||
errvalid++;
|
||||
strcpy(errbuf, "readExports: cannot read loader section header");
|
||||
snprintf(errbuf, sizeof(errbuf),
|
||||
"readExports: cannot read loader section header");
|
||||
while(ldclose(ldp) == FAILURE)
|
||||
;
|
||||
return -1;
|
||||
@@ -448,15 +457,16 @@ static int readExports(ModulePtr mp)
|
||||
*/
|
||||
if ((ldbuf = (char *)malloc(sh.s_size)) == NULL) {
|
||||
errvalid++;
|
||||
strcpy(errbuf, "readExports: ");
|
||||
strcat(errbuf, strerror(errno));
|
||||
snprintf (errbuf, sizeof(errbuf),
|
||||
"readExports: %s", strerror(errno));
|
||||
while(ldclose(ldp) == FAILURE)
|
||||
;
|
||||
return -1;
|
||||
}
|
||||
if (FSEEK(ldp, sh.s_scnptr, BEGINNING) != OKFSEEK) {
|
||||
errvalid++;
|
||||
strcpy(errbuf, "readExports: cannot seek to loader section");
|
||||
snprintf(errbuf, sizeof(errbuf),
|
||||
"readExports: cannot seek to loader section");
|
||||
free(ldbuf);
|
||||
while(ldclose(ldp) == FAILURE)
|
||||
;
|
||||
@@ -464,7 +474,8 @@ static int readExports(ModulePtr mp)
|
||||
}
|
||||
if (FREAD(ldbuf, sh.s_size, 1, ldp) != 1) {
|
||||
errvalid++;
|
||||
strcpy(errbuf, "readExports: cannot read loader section");
|
||||
snprintf(errbuf, sizeof(errbuf),
|
||||
"readExports: cannot read loader section");
|
||||
free(ldbuf);
|
||||
while(ldclose(ldp) == FAILURE)
|
||||
;
|
||||
@@ -482,8 +493,8 @@ static int readExports(ModulePtr mp)
|
||||
}
|
||||
if ((mp->exports = (ExportPtr)calloc(mp->nExports, sizeof(*mp->exports))) == NULL) {
|
||||
errvalid++;
|
||||
strcpy(errbuf, "readExports: ");
|
||||
strcat(errbuf, strerror(errno));
|
||||
snprintf (errbuf, sizeof(errbuf),
|
||||
"readExports: %s", strerror(errno));
|
||||
free(ldbuf);
|
||||
while(ldclose(ldp) == FAILURE)
|
||||
;
|
||||
@@ -508,8 +519,8 @@ static int readExports(ModulePtr mp)
|
||||
* must copy the first SYMNMLEN chars and make
|
||||
* sure we have a zero byte at the end.
|
||||
*/
|
||||
strncpy(tmpsym, ls->l_name, SYMNMLEN);
|
||||
tmpsym[SYMNMLEN] = '\0';
|
||||
strcpy_truncate (tmpsym, ls->l_name,
|
||||
SYMNMLEN + 1);
|
||||
symname = tmpsym;
|
||||
}
|
||||
ep->name = strdup(symname);
|
||||
@@ -537,8 +548,8 @@ static void * findMain(void)
|
||||
|
||||
if ((buf = malloc(size)) == NULL) {
|
||||
errvalid++;
|
||||
strcpy(errbuf, "findMain: ");
|
||||
strcat(errbuf, strerror(errno));
|
||||
snprintf (errbuf, sizeof(errbuf),
|
||||
"findMail: %s", strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
while ((i = loadquery(L_GETINFO, buf, size)) == -1 && errno == ENOMEM) {
|
||||
@@ -546,15 +557,15 @@ static void * findMain(void)
|
||||
size += 4*1024;
|
||||
if ((buf = malloc(size)) == NULL) {
|
||||
errvalid++;
|
||||
strcpy(errbuf, "findMain: ");
|
||||
strcat(errbuf, strerror(errno));
|
||||
snprintf (errbuf, sizeof(errbuf),
|
||||
"findMail: %s", strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (i == -1) {
|
||||
errvalid++;
|
||||
strcpy(errbuf, "findMain: ");
|
||||
strcat(errbuf, strerror(errno));
|
||||
snprintf (errbuf, sizeof(errbuf),
|
||||
"findMail: %s", strerror(errno));
|
||||
free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
@@ -10,6 +10,10 @@ Sun Apr 19 09:59:46 1998 Assar Westerlund <assar@sics.se>
|
||||
|
||||
* Makefile.in: add symlink magic for linux
|
||||
|
||||
Sat Feb 7 07:27:18 1998 Assar Westerlund <assar@sics.se>
|
||||
|
||||
* otp_db.c (otp_put): make sure we don't overrun `buf'
|
||||
|
||||
Sun Nov 9 07:14:59 1997 Assar Westerlund <assar@sics.se>
|
||||
|
||||
* otp_locl.h: use xdbm.h
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 1996, 1997 Kungliga Tekniska H<>gskolan
|
||||
* Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska H<>gskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -145,8 +145,7 @@ otp_get_internal (void *v, OtpContext *ctx, int lockp)
|
||||
p += 4;
|
||||
memcpy (ctx->key, p, OTPKEYSIZE);
|
||||
p += OTPKEYSIZE;
|
||||
strncpy (ctx->seed, p, sizeof(ctx->seed));
|
||||
ctx->seed[sizeof(ctx->seed) - 1] = '\0';
|
||||
strcpy_truncate (ctx->seed, p, sizeof(ctx->seed));
|
||||
if (lockp)
|
||||
return dbm_store (dbm, key, dat, DBM_REPLACE);
|
||||
else
|
||||
@@ -184,15 +183,29 @@ otp_put (void *v, OtpContext *ctx)
|
||||
datum dat, key;
|
||||
char buf[1024], *p;
|
||||
time_t zero = 0;
|
||||
size_t len, rem;
|
||||
|
||||
key.dsize = strlen(ctx->user);
|
||||
key.dptr = ctx->user;
|
||||
|
||||
p = buf;
|
||||
rem = sizeof(buf);
|
||||
|
||||
if (rem < sizeof(zero))
|
||||
return -1;
|
||||
memcpy (p, &zero, sizeof(zero));
|
||||
p += sizeof(zero);
|
||||
rem -= sizeof(zero);
|
||||
len = strlen(ctx->alg->name) + 1;
|
||||
|
||||
if (rem < len)
|
||||
return -1;
|
||||
strcpy (p, ctx->alg->name);
|
||||
p += strlen(p) + 1;
|
||||
p += len;
|
||||
rem -= len;
|
||||
|
||||
if (rem < 4)
|
||||
return -1;
|
||||
{
|
||||
unsigned char *up = (unsigned char *)p;
|
||||
*up++ = (ctx->n >> 24) & 0xFF;
|
||||
@@ -201,10 +214,20 @@ otp_put (void *v, OtpContext *ctx)
|
||||
*up++ = (ctx->n >> 0) & 0xFF;
|
||||
}
|
||||
p += 4;
|
||||
rem -= 4;
|
||||
|
||||
if (rem < OTPKEYSIZE)
|
||||
return -1;
|
||||
memcpy (p, ctx->key, OTPKEYSIZE);
|
||||
p += OTPKEYSIZE;
|
||||
rem -= OTPKEYSIZE;
|
||||
|
||||
len = strlen(ctx->seed) + 1;
|
||||
if (rem < len)
|
||||
return -1;
|
||||
strcpy (p, ctx->seed);
|
||||
p += strlen(p) + 1;
|
||||
p += len;
|
||||
rem -= len;
|
||||
dat.dptr = buf;
|
||||
dat.dsize = p - buf;
|
||||
return dbm_store (dbm, key, dat, DBM_REPLACE);
|
||||
|
@@ -88,15 +88,17 @@ otp_print_hex (OtpKey key, char *str, size_t sz)
|
||||
void
|
||||
otp_print_hex_extended (OtpKey key, char *str, size_t sz)
|
||||
{
|
||||
strncpy (str, OTP_HEXPREFIX, sz);
|
||||
str[sz-1] = '\0';
|
||||
otp_print_hex (key, str + strlen(OTP_HEXPREFIX), sz - strlen(OTP_HEXPREFIX));
|
||||
strcpy_truncate (str, OTP_HEXPREFIX, sz);
|
||||
otp_print_hex (key,
|
||||
str + strlen(OTP_HEXPREFIX),
|
||||
sz - strlen(OTP_HEXPREFIX));
|
||||
}
|
||||
|
||||
void
|
||||
otp_print_stddict_extended (OtpKey key, char *str, size_t sz)
|
||||
{
|
||||
strncpy (str, OTP_WORDPREFIX, sz);
|
||||
str[sz-1] = '\0';
|
||||
otp_print_stddict (key, str + strlen(OTP_WORDPREFIX), sz - strlen(OTP_WORDPREFIX));
|
||||
strcpy_truncate (str, OTP_WORDPREFIX, sz);
|
||||
otp_print_stddict (key,
|
||||
str + strlen(OTP_WORDPREFIX),
|
||||
sz - strlen(OTP_WORDPREFIX));
|
||||
}
|
||||
|
@@ -64,6 +64,11 @@ Thu Feb 12 03:30:08 1998 Assar Westerlund <assar@sics.se>
|
||||
|
||||
* parse_time.c (print_time_table): don't return a void value.
|
||||
|
||||
Tue Feb 3 11:06:24 1998 Johan Danielsson <joda@emma.pdc.kth.se>
|
||||
|
||||
* getarg.c (mandoc_template): Change date format to full month
|
||||
name, and day of month without leading zero.
|
||||
|
||||
Thu Jan 22 21:23:23 1998 Johan Danielsson <joda@emma.pdc.kth.se>
|
||||
|
||||
* getarg.c: Fix long form of negative flags.
|
||||
|
@@ -64,7 +64,7 @@ roken_vconcat (char *s, size_t len, va_list args)
|
||||
|
||||
if (n >= len)
|
||||
return -1;
|
||||
strncpy (s, a, n);
|
||||
memcpy (s, a, n);
|
||||
s += n;
|
||||
len -= n;
|
||||
}
|
||||
@@ -82,7 +82,6 @@ roken_vmconcat (char **s, size_t max_len, va_list args)
|
||||
p = malloc(1);
|
||||
if(p == NULL)
|
||||
return 0;
|
||||
*p = 0;
|
||||
len = 1;
|
||||
while ((a = va_arg(args, const char*))) {
|
||||
size_t n = strlen (a);
|
||||
@@ -97,9 +96,10 @@ roken_vmconcat (char **s, size_t max_len, va_list args)
|
||||
return 0;
|
||||
}
|
||||
p = q;
|
||||
memcpy (p + len - 1, a, n);
|
||||
len += n;
|
||||
strcat(p, a);
|
||||
}
|
||||
p[len - 1] = '\0';
|
||||
*s = p;
|
||||
return len;
|
||||
}
|
||||
|
@@ -97,12 +97,11 @@ mandoc_template(struct getargs *args,
|
||||
printf(".\\\" * use better macros for arguments (like .Pa for files)\n");
|
||||
printf(".\\\"\n");
|
||||
t = time(NULL);
|
||||
strftime(timestr, sizeof(timestr), "%b %d, %Y", localtime(&t));
|
||||
strftime(timestr, sizeof(timestr), "%B %e, %Y", localtime(&t));
|
||||
printf(".Dd %s\n", timestr);
|
||||
p = strrchr(__progname, '/');
|
||||
if(p) p++; else p = __progname;
|
||||
strncpy(cmd, p, sizeof(cmd));
|
||||
cmd[sizeof(cmd)-1] = '\0';
|
||||
strcpy_truncate(cmd, p, sizeof(cmd));
|
||||
strupr(cmd);
|
||||
|
||||
printf(".Dt %s SECTION\n", cmd);
|
||||
|
@@ -57,6 +57,6 @@ getcwd(char *path, size_t size)
|
||||
char *ret;
|
||||
ret = getwd(xxx);
|
||||
if(ret)
|
||||
strncpy(path, xxx, size);
|
||||
strcpy_truncate(path, xxx, size);
|
||||
return ret;
|
||||
}
|
||||
|
@@ -65,13 +65,11 @@ gethostname(char *name, int namelen)
|
||||
ret = uname (&utsname);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
strncpy (name, utsname.nodename, namelen);
|
||||
name[namelen-1] = '\0';
|
||||
strcpy_truncate (name, utsname.nodename, namelen);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
strncpy (name, "some.random.host", namelen);
|
||||
name[namelen-1] = '\0';
|
||||
strcpy_truncate (name, "some.random.host", namelen);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
@@ -748,7 +748,7 @@ g_opendir(Char *str, glob_t *pglob)
|
||||
char buf[MaxPathLen];
|
||||
|
||||
if (!*str)
|
||||
strcpy(buf, ".");
|
||||
strcpy_truncate(buf, ".", sizeof(buf));
|
||||
else
|
||||
g_Ctoc(str, buf);
|
||||
|
||||
|
@@ -84,12 +84,10 @@ inaddr2str(struct in_addr addr, char *s, size_t len)
|
||||
if(h)
|
||||
while ((p = *(h->h_addr_list)++))
|
||||
if (memcmp (p, &addr, sizeof(addr)) == 0) {
|
||||
strncpy (s, h->h_name, len);
|
||||
s[len - 1] = '\0';
|
||||
strcpy_truncate (s, h->h_name, len);
|
||||
return;
|
||||
}
|
||||
}
|
||||
strncpy (s, inet_ntoa (addr), len);
|
||||
s[len - 1] = '\0';
|
||||
strcpy_truncate (s, inet_ntoa (addr), len);
|
||||
return;
|
||||
}
|
||||
|
@@ -127,8 +127,7 @@ __ivaliduser(FILE *hostf, unsigned raddr, const char *luser,
|
||||
sizeof(u_long),
|
||||
AF_INET)) == NULL)
|
||||
return (-1);
|
||||
strncpy(hname, hp->h_name, sizeof(hname));
|
||||
hname[sizeof(hname) - 1] = '\0';
|
||||
strcpy_truncate(hname, hp->h_name, sizeof(hname));
|
||||
|
||||
while (fgets(buf, sizeof(buf), hostf)) {
|
||||
p = buf;
|
||||
@@ -257,8 +256,7 @@ again:
|
||||
first = 0;
|
||||
if ((pwd = k_getpwnam((char*)luser)) == NULL)
|
||||
return (-1);
|
||||
strcpy(pbuf, pwd->pw_dir);
|
||||
strcat(pbuf, "/.rhosts");
|
||||
snprintf (pbuf, sizeof(pbuf), "%s/.rhosts", pwd->pw_dir);
|
||||
|
||||
/*
|
||||
* Change effective uid while opening .rhosts. If root and
|
||||
|
@@ -193,6 +193,14 @@ char *strtok_r(char *s1, const char *s2, char **lasts);
|
||||
char * strupr(char *);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRCPY_TRUNCATE
|
||||
int strcpy_truncate (char *dst, const char *src, size_t dst_sz);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRCAT_TRUNCATE
|
||||
int strcat_truncate (char *dst, const char *src, size_t dst_sz);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_GETDTABLESIZE
|
||||
int getdtablesize(void);
|
||||
#endif
|
||||
|
@@ -70,6 +70,7 @@ struct state {
|
||||
/* XXX - methods */
|
||||
};
|
||||
|
||||
#ifndef HAVE_VSNPRINTF
|
||||
static int
|
||||
sn_reserve (struct state *state, size_t n)
|
||||
{
|
||||
@@ -86,6 +87,7 @@ sn_append_char (struct state *state, char c)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
as_reserve (struct state *state, size_t n)
|
||||
|
@@ -43,6 +43,8 @@
|
||||
|
||||
RCSID("$Id$");
|
||||
|
||||
#ifndef HAVE_STRCPY_TRUNCATE
|
||||
|
||||
int
|
||||
strcpy_truncate (char *dst, const char *src, size_t dst_sz)
|
||||
{
|
||||
@@ -59,3 +61,5 @@ strcpy_truncate (char *dst, const char *src, size_t dst_sz)
|
||||
else
|
||||
return dst_sz;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 1996, 1997 Kungliga Tekniska H<>gskolan
|
||||
* Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska H<>gskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -56,7 +56,7 @@ strerror(int eno)
|
||||
if(eno < 0 || eno >= sys_nerr)
|
||||
snprintf(emsg, sizeof(emsg), "Error %d occurred.", eno);
|
||||
else
|
||||
strcpy(emsg, sys_errlist[eno]);
|
||||
snprintf(emsg, sizeof(emsg), "%s", sys_errlist[eno]);
|
||||
|
||||
return emsg;
|
||||
}
|
||||
|
@@ -43,6 +43,8 @@
|
||||
|
||||
RCSID("$Id$");
|
||||
|
||||
#ifndef HAVE_STRCPY_TRUNCATE
|
||||
|
||||
int
|
||||
strcpy_truncate (char *dst, const char *src, size_t dst_sz)
|
||||
{
|
||||
@@ -59,3 +61,5 @@ strcpy_truncate (char *dst, const char *src, size_t dst_sz)
|
||||
else
|
||||
return dst_sz;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -51,6 +51,10 @@ Sun Feb 15 05:12:11 1998 Johan Danielsson <joda@emma.pdc.kth.se>
|
||||
|
||||
* sl.c: Move command line split to function `sl_make_argv'.
|
||||
|
||||
Tue Feb 3 16:45:44 1998 Johan Danielsson <joda@emma.pdc.kth.se>
|
||||
|
||||
* sl.c: Add sl_command_loop, that is the loop body of sl_loop.
|
||||
|
||||
Mon Oct 20 01:13:21 1997 Assar Westerlund <assar@sics.se>
|
||||
|
||||
* sl.c (sl_help): actually use the `help' field of `SL_cmd'
|
||||
|
67
lib/sl/sl.c
67
lib/sl/sl.c
@@ -143,6 +143,11 @@ sl_command(SL_cmd *cmds, int argc, char **argv)
|
||||
return (*c->func)(argc, argv);
|
||||
}
|
||||
|
||||
struct sl_data {
|
||||
int max_count;
|
||||
char **ptr;
|
||||
};
|
||||
|
||||
int
|
||||
sl_make_argv(char *line, int *ret_argc, char ***ret_argv)
|
||||
{
|
||||
@@ -178,39 +183,47 @@ sl_make_argv(char *line, int *ret_argc, char ***ret_argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* return values: 0 on success, -1 on fatal error, or return value of command */
|
||||
int
|
||||
sl_loop (SL_cmd *cmds, char *prompt)
|
||||
sl_command_loop(SL_cmd *cmds, char *prompt, void **data)
|
||||
{
|
||||
int ret = 0;
|
||||
char *buf;
|
||||
SL_cmd *c;
|
||||
int argc;
|
||||
char **argv;
|
||||
int ret = 0;
|
||||
|
||||
ret = 0;
|
||||
buf = readline(prompt);
|
||||
if(buf == NULL)
|
||||
return 1;
|
||||
|
||||
while(ret == 0) {
|
||||
ret = 0;
|
||||
/* XXX should make sure this doesn't do funny things if stdin
|
||||
is not a tty */
|
||||
buf = readline(prompt);
|
||||
if(buf == NULL)
|
||||
break;
|
||||
|
||||
if(*buf)
|
||||
add_history(buf);
|
||||
argc = 0;
|
||||
ret = sl_make_argv(buf, &argc, &argv);
|
||||
if(ret) {
|
||||
fprintf(stderr, "sl_loop: out of memory\n");
|
||||
return -1;
|
||||
}
|
||||
if(argc >= 1) {
|
||||
ret = sl_command(cmds, argc, argv);
|
||||
if(ret == -1) {
|
||||
printf ("Unrecognized command: %s\n", argv[0]);
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
free(argv);
|
||||
if(*buf)
|
||||
add_history(buf);
|
||||
ret = sl_make_argv(buf, &argc, &argv);
|
||||
if(ret) {
|
||||
fprintf(stderr, "sl_loop: out of memory\n");
|
||||
free(buf);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
if (argc >= 1) {
|
||||
ret = sl_command(cmds, argc, argv);
|
||||
if(ret == -1) {
|
||||
printf ("Unrecognized command: %s\n", argv[0]);
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
free(buf);
|
||||
free(argv);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
sl_loop(SL_cmd *cmds, char *prompt)
|
||||
{
|
||||
void *data = NULL;
|
||||
int ret;
|
||||
while((ret = sl_command_loop(cmds, prompt, &data)) == 0)
|
||||
;
|
||||
return ret;
|
||||
}
|
||||
|
@@ -54,6 +54,7 @@ typedef struct sl_cmd SL_cmd;
|
||||
|
||||
void sl_help (SL_cmd *, int argc, char **argv);
|
||||
int sl_loop (SL_cmd *, char *prompt);
|
||||
int sl_command_loop (SL_cmd *cmds, char *prompt, void **data);
|
||||
int sl_command (SL_cmd *cmds, int argc, char **argv);
|
||||
int sl_make_argv(char*, int*, char***);
|
||||
|
||||
|
Reference in New Issue
Block a user