Skip to content

Commit

Permalink
Fix some Wstringop-truncation
Browse files Browse the repository at this point in the history
  • Loading branch information
x42 committed Sep 16, 2019
1 parent 2d48d09 commit 7ea71bc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
6 changes: 4 additions & 2 deletions b_synth/lv2.c
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,8 @@ iowork (B3S* b3s, const LV2_Atom_Object* obj, int cmd)
w.cmd = cmd;
w.status = -1;
;
strncpy (w.msg, (char*)LV2_ATOM_BODY (name), 1024);
strncpy (w.msg, (char*)LV2_ATOM_BODY (name), 1023);
w.msg[1023] = '\0';
b3s->schedule->schedule_work (b3s->schedule->handle, sizeof (struct worknfo), &w);
}
}
Expand All @@ -891,7 +892,8 @@ advanced_config_set (B3S* b3s, const LV2_Atom_Object* obj)
w.cmd = CMD_SETCFG;
}
w.status = -1;
strncpy (w.msg, msg, 1024);
strncpy (w.msg, msg, 1023);
w.msg[1023] = '\0';
b3s->schedule->schedule_work (b3s->schedule->handle, sizeof (struct worknfo), &w);
}
}
Expand Down
13 changes: 8 additions & 5 deletions b_synth/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,8 @@ dirlist (PuglView* view, const char* dir)
}
filelist = (char**)realloc (filelist, (filelistlen + 1) * sizeof (char*));
filelist[filelistlen] = (char*)malloc (1024 * sizeof (char));
strncpy (filelist[filelistlen], dd->d_name, 1024);
strncpy (filelist[filelistlen], dd->d_name, 1023);
filelist[filelistlen][1023] = '\0';
filelistlen++;
free (rfn);
continue;
Expand Down Expand Up @@ -1713,7 +1714,8 @@ txtentry_start (PuglView* view, const char* title, const char* defaulttext)
if (!defaulttext) {
ui->textentry_text[0] = '\0';
} else {
strncpy (ui->textentry_text, defaulttext, 1024);
strncpy (ui->textentry_text, defaulttext, 1023);
ui->textentry_text[1023] = '\0';
}
sprintf (ui->textentry_title, "%s", title);
ui->textentry_active = 1;
Expand Down Expand Up @@ -2321,7 +2323,8 @@ cfg_parse_config (B3ui* ui, const char* key, const char* value)
int relevant = 0;
int i;
if (!strcmp ("lv2.info", key)) {
strncpy (ui->lv2nfo, value, 128);
strncpy (ui->lv2nfo, value, 127);
ui->lv2nfo[127] = '\0';
return;
}
for (i = 0; i < MAXCFG; ++i) {
Expand Down Expand Up @@ -5313,8 +5316,8 @@ port_event (LV2UI_Handle handle,
}
puglPostRedisplay (ui->view);
} else if (!get_pgm_midi_mapping (&ui->uris, obj, &v, &fn, &dsc)) {
strncpy (ui->midipgm[v], fn, 32);
strncpy (ui->mididsc[v], dsc, 256);
strncpy (ui->midipgm[v], fn, 31);
strncpy (ui->mididsc[v], dsc, 255);
ui->midipgm[v][31] = '\0';
ui->mididsc[v][255] = '\0';
puglPostRedisplay (ui->view);
Expand Down
2 changes: 1 addition & 1 deletion src/pgmParser.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ parseIdentifier (ParserState* ps, char* identifier)
return P_ERROR;
} else {
/* Should be a setter function */
strncpy (identifier, ps->stringBuffer, SYMBOLSIZE);
strncpy (identifier, ps->stringBuffer, SYMBOLSIZE - 1);
identifier[SYMBOLSIZE - 1] = '\0';
}
(void)getNextToken (ps);
Expand Down

0 comments on commit 7ea71bc

Please sign in to comment.