* Message length is at most 80, not 79 characters

* Improve dgl-wall's handling of bad arguments


git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@254 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
Jilles Tjoelker 2004-02-22 22:40:33 +00:00
parent 6afc30c0b2
commit 2316fddf78
2 changed files with 14 additions and 11 deletions

View File

@ -511,7 +511,7 @@ void
domailuser (char *username)
{
unsigned int len, i;
char *spool_fn, message[80];
char *spool_fn, message[81];
FILE *user_spool = NULL;
time_t now;
int mail_empty = 1;

View File

@ -18,7 +18,7 @@ int
main (int argc, char** argv)
{
int c, i, len;
char buf[80], *ptr = buf, *from = NULL;
char buf[82], *ptr = buf, *from = NULL;
struct dg_game ** games = NULL;
struct flock fl = { 0 };
struct passwd* pw = getpwuid(getuid());
@ -41,6 +41,8 @@ main (int argc, char** argv)
case 'F':
from = strdup(optarg);
break;
default:
goto usage;
}
}
@ -49,19 +51,20 @@ main (int argc, char** argv)
while (optind < argc)
{
if (strlen(buf) >= 80)
{
fprintf(stderr, "Error: Message is too long! (80 chars max)\n");
return 1;
}
else if (strlen(buf) != 0)
strlcat (buf, " ", 80);
strlcat (buf, argv[optind++], 80);
if (strlen(buf) != 0)
strlcat (buf, " ", sizeof(buf));
strlcat (buf, argv[optind++], sizeof(buf));
}
if (strlen(buf) > 80)
{
fprintf(stderr, "Error: Message is too long! (80 chars max)\n");
return 1;
}
if (strlen(buf) == 0)
{
fprintf(stderr, "Error: no message?\n");
usage:
fprintf(stderr, "Usage: %s [-f config] [-F fromname] message\n", argv[0]);
return 1;
}