diff options
| author | Simon <simon@hardwired.org.uk> | 2011-04-06 12:14:13 (GMT) |
|---|---|---|
| committer | Simon <simon@hardwired.org.uk> | 2011-04-06 12:14:13 (GMT) |
| commit | ca02640ebb1f6e2bf4c400df638f979108c20556 (patch) | |
| tree | d44b52ab16e0f5b04049cd4d0d2e2255fa23b508 /src/interface.c | |
| parent | 1bc97fcc370c6d8197482b3cc1df6413e0bcd765 (diff) | |
| download | powder-ca02640ebb1f6e2bf4c400df638f979108c20556.zip powder-ca02640ebb1f6e2bf4c400df638f979108c20556.tar.gz | |
Avoid potential overflow when pasting long text strings
Diffstat (limited to 'src/interface.c')
| -rw-r--r-- | src/interface.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/interface.c b/src/interface.c index 1e8f44b..98db488 100644 --- a/src/interface.c +++ b/src/interface.c @@ -395,9 +395,9 @@ void ui_edit_process(int mx, int my, int mb, ui_edit *ed) } else if(sdl_mod & (KMOD_CTRL) && sdl_key=='v')//paste { - char *paste = "foo"; //clipboard_pull_text(); + char *paste = clipboard_pull_text(); int pl = strlen(paste); - if ((textwidth(str)+textwidth(paste) > ed->w-14 && !ed->multiline) || (float)(((textwidth(str)+textwidth(paste))/(ed->w-14)*12) > ed->h && ed->multiline)) + if ((textwidth(str)+textwidth(paste) > ed->w-14 && !ed->multiline) || (pl+strlen(ed->str)>255) || (float)(((textwidth(str)+textwidth(paste))/(ed->w-14)*12) > ed->h && ed->multiline)) break; memmove(ed->str+ed->cursor+pl, ed->str+ed->cursor, l+pl-ed->cursor); memcpy(ed->str+ed->cursor,paste,pl); |
