(typed_wu): Treat overlong message as internal error instead of just
truncating it silently. Simplify.
This commit is contained in:
parent
bc8a443264
commit
ff27a2644f
1 changed files with 20 additions and 8 deletions
|
@ -78,7 +78,15 @@ telegram_is_new(natid to, struct telstr *tel)
|
||||||
return is_new;
|
return is_new;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*VARARGS*/
|
/*
|
||||||
|
* Send a telegram from FROM to TO.
|
||||||
|
* Format text to send under control of printf-style FORMAT using
|
||||||
|
* optional arguments. It is plain ASCII.
|
||||||
|
* If running from the update, telegram type is TEL_UPDATE.
|
||||||
|
* Else if FROM is a deity, type is TEL_BULLETIN.
|
||||||
|
* Else it is TEL_NORM.
|
||||||
|
* Return 0 on success, -1 on error.
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
wu(natid from, natid to, char *format, ...)
|
wu(natid from, natid to, char *format, ...)
|
||||||
{
|
{
|
||||||
|
@ -98,10 +106,15 @@ wu(natid from, natid to, char *format, ...)
|
||||||
return typed_wu(from, to, buf, TEL_NORM);
|
return typed_wu(from, to, buf, TEL_NORM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Send a telegram from FROM to TO.
|
||||||
|
* MESSAGE is the text to send, encoded as message text.
|
||||||
|
* TYPE is the telegram type.
|
||||||
|
* Return 0 on success, -1 on error.
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
typed_wu(natid from, natid to, char *message, int type)
|
typed_wu(natid from, natid to, char *message, int type)
|
||||||
{
|
{
|
||||||
char *bp;
|
|
||||||
int len;
|
int len;
|
||||||
struct telstr tel;
|
struct telstr tel;
|
||||||
struct natstr *np;
|
struct natstr *np;
|
||||||
|
@ -136,12 +149,11 @@ typed_wu(natid from, natid to, char *message, int type)
|
||||||
}
|
}
|
||||||
tel.tel_from = from;
|
tel.tel_from = from;
|
||||||
(void)time(&tel.tel_date);
|
(void)time(&tel.tel_date);
|
||||||
bp = message;
|
len = strlen(message);
|
||||||
while (*bp++) ;
|
if (CANT_HAPPEN(len > MAXTELSIZE)) {
|
||||||
len = bp - message;
|
len = MAXTELSIZE;
|
||||||
if (len >= MAXTELSIZE)
|
message[len] = 0;
|
||||||
len = (MAXTELSIZE - 1);
|
}
|
||||||
message[len] = 0;
|
|
||||||
tel.tel_length = len;
|
tel.tel_length = len;
|
||||||
tel.tel_type = type;
|
tel.tel_type = type;
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue