(comm_bomb, ship_bomb, land_bomb, pinflak_planedamage): Fix dangerous
misuse of pr(), PR() and mpr(): 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
ade364fa1d
commit
65168f0d93
1 changed files with 10 additions and 17 deletions
|
@ -430,8 +430,8 @@ comm_bomb(struct emp_qelem *list, struct sctstr *target)
|
||||||
for (i = 0; i < nbomb; i++) {
|
for (i = 0; i < nbomb; i++) {
|
||||||
if (opt_SUPER_BARS && bombcomm[i] == I_BAR)
|
if (opt_SUPER_BARS && bombcomm[i] == I_BAR)
|
||||||
continue;
|
continue;
|
||||||
pr(i == 0 ? "Bombable: " : ", ");
|
pr("%s%s", i == 0 ? "Bombable: " : ", ",
|
||||||
pr(ichr[bombcomm[i]].i_name);
|
ichr[bombcomm[i]].i_name);
|
||||||
}
|
}
|
||||||
pr("\n");
|
pr("\n");
|
||||||
} else
|
} else
|
||||||
|
@ -483,7 +483,6 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
|
||||||
struct shiplist *head = NULL;
|
struct shiplist *head = NULL;
|
||||||
s_char buf[1024];
|
s_char buf[1024];
|
||||||
s_char prompt[128];
|
s_char prompt[128];
|
||||||
s_char msg[128];
|
|
||||||
int hitchance;
|
int hitchance;
|
||||||
int nukedam;
|
int nukedam;
|
||||||
int flak;
|
int flak;
|
||||||
|
@ -554,9 +553,8 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
|
||||||
flak = (int)(techfact(ship.shp_tech, (double)gun) * 2.0);
|
flak = (int)(techfact(ship.shp_tech, (double)gun) * 2.0);
|
||||||
ship.shp_item[I_SHELL] = shell;
|
ship.shp_item[I_SHELL] = shell;
|
||||||
putship(ship.shp_uid, &ship);
|
putship(ship.shp_uid, &ship);
|
||||||
sprintf(msg, "Flak! Firing %d guns from ship %s\n",
|
PR(ship.shp_own, "Flak! Firing %d guns from ship %s\n",
|
||||||
flak, prship(&ship));
|
flak, prship(&ship));
|
||||||
PR(ship.shp_own, msg);
|
|
||||||
if (pinflak_planedamage(&plp->plane, plp->pcp, ship.shp_own, flak))
|
if (pinflak_planedamage(&plp->plane, plp->pcp, ship.shp_own, flak))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -731,7 +729,6 @@ land_bomb(struct emp_qelem *list, struct sctstr *target)
|
||||||
natid own;
|
natid own;
|
||||||
s_char prompt[128];
|
s_char prompt[128];
|
||||||
s_char buf[1024];
|
s_char buf[1024];
|
||||||
s_char msg[128];
|
|
||||||
struct lndstr land;
|
struct lndstr land;
|
||||||
struct emp_qelem *qp;
|
struct emp_qelem *qp;
|
||||||
int unitno;
|
int unitno;
|
||||||
|
@ -780,10 +777,9 @@ land_bomb(struct emp_qelem *list, struct sctstr *target)
|
||||||
|
|
||||||
flak = (int)(techfact(land.lnd_tech, (double)land.lnd_aaf) * 3.0);
|
flak = (int)(techfact(land.lnd_tech, (double)land.lnd_aaf) * 3.0);
|
||||||
if (flak) {
|
if (flak) {
|
||||||
sprintf(msg,
|
PR(land.lnd_own,
|
||||||
"Flak! Firing flak guns from unit %s (aa rating %d)\n",
|
"Flak! Firing flak guns from unit %s (aa rating %d)\n",
|
||||||
prland(&land), land.lnd_aaf);
|
prland(&land), land.lnd_aaf);
|
||||||
PR(land.lnd_own, msg);
|
|
||||||
if (pinflak_planedamage(&plp->plane, plp->pcp, land.lnd_own, flak))
|
if (pinflak_planedamage(&plp->plane, plp->pcp, land.lnd_own, flak))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -813,8 +809,7 @@ land_bomb(struct emp_qelem *list, struct sctstr *target)
|
||||||
dam = 100;
|
dam = 100;
|
||||||
own = land.lnd_own;
|
own = land.lnd_own;
|
||||||
if (own != 0)
|
if (own != 0)
|
||||||
mpr(own,
|
mpr(own, "%s pinpoint bombing raid did %d damage to %s\n",
|
||||||
"%s pinpoint bombing raid did %d damage to %s\n",
|
|
||||||
cname(player->cnum), dam, prland(&land));
|
cname(player->cnum), dam, prland(&land));
|
||||||
check_retreat_and_do_landdamage(&land, dam);
|
check_retreat_and_do_landdamage(&land, dam);
|
||||||
|
|
||||||
|
@ -869,7 +864,6 @@ pinflak_planedamage(struct plnstr *pp, struct plchrstr *pcp, natid from,
|
||||||
int disp;
|
int disp;
|
||||||
s_char dmess[255];
|
s_char dmess[255];
|
||||||
int eff;
|
int eff;
|
||||||
s_char mesg[128];
|
|
||||||
struct shpstr ship;
|
struct shpstr ship;
|
||||||
struct lndstr land;
|
struct lndstr land;
|
||||||
natid plane_owner;
|
natid plane_owner;
|
||||||
|
@ -897,9 +891,8 @@ pinflak_planedamage(struct plnstr *pp, struct plchrstr *pcp, natid from,
|
||||||
sprintf(dmess, " -- aborted with %d%%%% damage", 100 - eff);
|
sprintf(dmess, " -- aborted with %d%%%% damage", 100 - eff);
|
||||||
disp = 2;
|
disp = 2;
|
||||||
}
|
}
|
||||||
sprintf(mesg, " Flak! %s %s takes %d%s.\n",
|
PR(plane_owner, " Flak! %s %s takes %d%s.\n",
|
||||||
cname(pp->pln_own), prplane(pp), dam, dmess);
|
cname(pp->pln_own), prplane(pp), dam, dmess);
|
||||||
PR(plane_owner, mesg);
|
|
||||||
|
|
||||||
pp->pln_effic = eff;
|
pp->pln_effic = eff;
|
||||||
if (disp == 1) {
|
if (disp == 1) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue