#else
bzero(&utmp, sizeof(struct utmp));
- strncpy(utmp.ut_id, d->utmpId, sizeof(u->ut_id));
+ strncpy(utmp.ut_id, d->utmpId, sizeof(u->ut_id) - 1);
utmp.ut_type = LOGIN_PROCESS;
setutent();
{
ChoicePtr c;
int insert;
- int found;
+ int found = 0;
Debug ("Got indirect choice back (%s)\n", Print8Address(clientAddress));
for (c = choices; c; c = c->next) {
Debug("Check %s: status=%d wakeupTime=%d\n", d->name,
d->status, wakeupTime);
if (d->status == suspended && wakeupTime >= 0)
- if ( GettyRunning(d) || (strcmp(d->gettyLine,"??") == 0))
+ if ( GettyRunning(d) || (d->gettyLine && (strcmp(d->gettyLine,"??") == 0)) )
if ( wakeupTime == 0 ) {
Debug("Polling of suspended server %s started.\n",
d->name);
p = DisplayName;
- strncpy(p, d->name, sizeof(DisplayName));
+ strncpy(p, d->name, sizeof(DisplayName) - 1);
DisplayName[sizeof(DisplayName)-1] = '\0';
if ( (s = strchr(p,':')) != NULL )
strcpy(utmp.ut_line,ttynm);
close(fd);
}
- else
- strncpy(utmp.ut_line, d->gettyLine, sizeof(utmp.ut_line));
+ else
+ {
+ strncpy(utmp.ut_line, d->gettyLine, sizeof(utmp.ut_line) - 1);
+ utmp.ut_line[sizeof(utmp.ut_line) - 1] = 0;
+ }
#else
- strncpy(utmp.ut_line, d->gettyLine, sizeof(utmp.ut_line));
+ strncpy(utmp.ut_line, d->gettyLine, sizeof(utmp.ut_line) - 1);
+ utmp.ut_line[sizeof(utmp.ut_line) - 1] = 0;
#endif
Debug("Checking for a getty on line %s.\n", utmp.ut_line);
return;
}
- n = read(f2, buf, BUFSIZ);
+ memset(buf, 0, BUFSIZ);
+ n = read(f2, buf, BUFSIZ - 1);
if ( (p = strchr(buf,'\n')) != NULL ) {
p++;
struct passwd *puser)
{
char **args, **argv, **a;
- char *name, *class, *type;
+ char *name = NULL, *class, *type;
struct display *d;
int usedDefaultType;
int parse_uid;
freeArgs (args);
return 0;
}
- name = args[0];
+ name = strdup(args[0]);
if (!args[1])
{
LogError(ReadCatalog(MC_LOG_SET,MC_LOG_MISS_TYPE,MC_DEF_LOG_MISS_TYPE),
char tname[128];
struct hostent *hostent;
- strcpy(tname,"");
- gethostname(tname, sizeof(tname));
+ memset(tname, 0, 128);
+ gethostname(tname, 128 - 1);
if ( (hostent = gethostbyname(tname)) == NULL ) {
LogError(
ReadCatalog(MC_LOG_SET,MC_LOG_INV_HOSTNM,MC_DEF_LOG_INV_HOSTNM),
tname);
- strcpy(tname,"");
+ tname[0] = 0;
}
-/*
- else
- strcpy(tname,hostent->h_name);
-*/
- strcat(tname, ":0");
+ strncat(tname, ":0", 128 - 1);
- name = tname;
+ free(name);
+ name = strdup(tname);
}
/*
freeSomeArgs (args, argv - args);
+ free(name);
return 1;
}