Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v.in.dwg: Avoid using same variable as parameter and destination in sprintf #4262

Merged
merged 1 commit into from
Sep 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions vector/v.in.dwg/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ int main(int argc, char *argv[])
struct GModule *module;
struct Option *out_opt, *in_opt;
struct Flag *z_flag, *circle_flag, *l_flag, *int_flag;
char buf[2000];
const size_t BUFSIZE = 2000;
char buf[BUFSIZE];

/* DWG */
char path[2000];
Expand Down Expand Up @@ -135,10 +136,13 @@ int main(int argc, char *argv[])
/* Init OpenDWG */
sprintf(path, "%s/etc/adinit.dat", G_gisbase());
if (!adInitAd2(path, &initerror)) {
sprintf(buf, _("Unable to initialize OpenDWG Toolkit, error: %d: %s."),
initerror, adErrorStr(initerror));
snprintf(buf, BUFSIZE,
_("Unable to initialize OpenDWG Toolkit, error: %d: %s."),
initerror, adErrorStr(initerror));
size_t buflen = strlen(buf);
if (initerror == AD_UNABLE_TO_OPEN_INIT_FILE)
sprintf(buf, _("%s Cannot open %s"), buf, path);
snprintf(buf + buflen, BUFSIZE - buflen, _(" Cannot open %s"),
path);
G_fatal_error(buf);
}
adSetupDwgRead();
Expand Down
Loading