The format argument to a printf-like routine should either be a constant
string or a variable *known* to point to a format string. It should not
be an arbitrary string you're trying to print - if that string contains
% characters, they will be interpreted as part of a format
specification, which can cause crashes (e.g., "%s", if what appears to
be an argument corresponding to that %s, when interpreted as a pointer,
doesn't point to a valid string) or other incorrect behavior.
If you want to print a string, use "%s" as the format and the string as
the argument.
ND_PRINT((ndo, "\n\t sname \""));
if (fn_print(bp->bp_sname, ndo->ndo_snapend)) {
ND_PRINT((ndo, "\""));
- ND_PRINT((ndo, tstr + 1));
+ ND_PRINT((ndo, "%s", tstr + 1));
return;
}
ND_PRINT((ndo, "\""));
ND_PRINT((ndo, "\n\t file \""));
if (fn_print(bp->bp_file, ndo->ndo_snapend)) {
ND_PRINT((ndo, "\""));
- ND_PRINT((ndo, tstr + 1));
+ ND_PRINT((ndo, "%s", tstr + 1));
return;
}
ND_PRINT((ndo, "\""));