(gift, load_comm_ship, load_comm_land): Fix dangerous misuse of wu():
passed formatted string instead of format string and arguments. Crash bug if formatted string contains '%'. Players can put that in ship names...
This commit is contained in:
parent
0d0a305bf3
commit
a6843eeba6
1 changed files with 18 additions and 38 deletions
|
@ -321,12 +321,11 @@ lload(void)
|
||||||
void
|
void
|
||||||
gift(int givee, int giver, s_char *ptr, int type, s_char *mesg)
|
gift(int givee, int giver, s_char *ptr, int type, s_char *mesg)
|
||||||
{
|
{
|
||||||
s_char *p, line[256];
|
s_char *p;
|
||||||
|
|
||||||
if (giver == givee)
|
if (giver == givee)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EF_SHIP:
|
case EF_SHIP:
|
||||||
p = prship((struct shpstr *)ptr);
|
p = prship((struct shpstr *)ptr);
|
||||||
|
@ -342,8 +341,7 @@ gift(int givee, int giver, s_char *ptr, int type, s_char *mesg)
|
||||||
p = "a red herring";
|
p = "a red herring";
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(line, "%s %s %s\n", cname(giver), p, mesg);
|
wu(0, givee, "%s %s %s\n", cname(giver), p, mesg);
|
||||||
wu(0, givee, line);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -778,30 +776,21 @@ load_comm_ship(struct sctstr *sectp, struct shpstr *sp,
|
||||||
sp->shp_item[item] = ship_amt + move_amt;
|
sp->shp_item[item] = ship_amt + move_amt;
|
||||||
if (move_amt >= 0) {
|
if (move_amt >= 0) {
|
||||||
pr("%d %s loaded onto %s at %s\n",
|
pr("%d %s loaded onto %s at %s\n",
|
||||||
move_amt,
|
move_amt, ich->i_name,
|
||||||
ich->i_name,
|
|
||||||
prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
|
prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
|
||||||
if (sp->shp_own != player->cnum) {
|
if (sp->shp_own != player->cnum) {
|
||||||
sprintf(buf, "%s loaded %d %s onto %s at %s\n",
|
wu(0, sp->shp_own, "%s loaded %d %s onto %s at %s\n",
|
||||||
cname(player->cnum),
|
cname(player->cnum), move_amt, ich->i_name,
|
||||||
move_amt,
|
prship(sp), xyas(sp->shp_x, sp->shp_y, sp->shp_own));
|
||||||
ich->i_name,
|
|
||||||
prship(sp), xyas(sp->shp_x, sp->shp_y, sp->shp_own));
|
|
||||||
wu(0, sp->shp_own, buf);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pr("%d %s unloaded from %s at %s\n",
|
pr("%d %s unloaded from %s at %s\n",
|
||||||
-move_amt,
|
-move_amt, ich->i_name,
|
||||||
ich->i_name,
|
|
||||||
prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
|
prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
|
||||||
if (sectp->sct_own != player->cnum) {
|
if (sectp->sct_own != player->cnum) {
|
||||||
sprintf(buf, "%s unloaded %d %s from %s at %s\n",
|
wu(0, sectp->sct_own, "%s unloaded %d %s from %s at %s\n",
|
||||||
cname(player->cnum),
|
cname(player->cnum), -move_amt, ich->i_name,
|
||||||
-move_amt,
|
prship(sp), xyas(sp->shp_x, sp->shp_y, sectp->sct_own));
|
||||||
ich->i_name,
|
|
||||||
prship(sp),
|
|
||||||
xyas(sp->shp_x, sp->shp_y, sectp->sct_own));
|
|
||||||
wu(0, sectp->sct_own, buf);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++*nshipsp;
|
++*nshipsp;
|
||||||
|
@ -985,30 +974,21 @@ load_comm_land(struct sctstr *sectp, struct lndstr *lp,
|
||||||
lp->lnd_harden = 0;
|
lp->lnd_harden = 0;
|
||||||
if (move_amt >= 0) {
|
if (move_amt >= 0) {
|
||||||
pr("%d %s loaded onto %s at %s\n",
|
pr("%d %s loaded onto %s at %s\n",
|
||||||
move_amt,
|
move_amt, ich->i_name,
|
||||||
ich->i_name,
|
|
||||||
prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));
|
prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));
|
||||||
if (lp->lnd_own != player->cnum) {
|
if (lp->lnd_own != player->cnum) {
|
||||||
sprintf(buf, "%s loaded %d %s onto %s at %s\n",
|
wu(0, lp->lnd_own, "%s loaded %d %s onto %s at %s\n",
|
||||||
cname(player->cnum),
|
cname(player->cnum), move_amt, ich->i_name,
|
||||||
move_amt,
|
prland(lp), xyas(lp->lnd_x, lp->lnd_y, lp->lnd_own));
|
||||||
ich->i_name,
|
|
||||||
prland(lp), xyas(lp->lnd_x, lp->lnd_y, lp->lnd_own));
|
|
||||||
wu(0, lp->lnd_own, buf);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pr("%d %s unloaded from %s at %s\n",
|
pr("%d %s unloaded from %s at %s\n",
|
||||||
-move_amt,
|
-move_amt, ich->i_name,
|
||||||
ich->i_name,
|
|
||||||
prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));
|
prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));
|
||||||
if (sectp->sct_own != player->cnum) {
|
if (sectp->sct_own != player->cnum) {
|
||||||
sprintf(buf, "%s unloaded %d %s from %s at %s\n",
|
wu(0, sectp->sct_own, "%s unloaded %d %s from %s at %s\n",
|
||||||
cname(player->cnum),
|
cname(player->cnum), -move_amt, ich->i_name,
|
||||||
-move_amt,
|
prland(lp), xyas(lp->lnd_x, lp->lnd_y, sectp->sct_own));
|
||||||
ich->i_name,
|
|
||||||
prland(lp),
|
|
||||||
xyas(lp->lnd_x, lp->lnd_y, sectp->sct_own));
|
|
||||||
wu(0, sectp->sct_own, buf);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++*nunitsp;
|
++*nunitsp;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue