diff options
author | fvogelnew1@free.fr <fvogel> | 2016-04-04 18:01:17 (GMT) |
---|---|---|
committer | fvogelnew1@free.fr <fvogel> | 2016-04-04 18:01:17 (GMT) |
commit | 73814315991955bca8ffb2c3918830b390c0ac04 (patch) | |
tree | f488502bf2d14b2e02f3ec5ffae06b7e04c43295 | |
parent | 533cff221432191c73b25f84540ca7f3b3c124b7 (diff) | |
parent | c65ebee6d20f49f483d99b817deda9e92b2eb141 (diff) | |
download | tk-73814315991955bca8ffb2c3918830b390c0ac04.zip tk-73814315991955bca8ffb2c3918830b390c0ac04.tar.gz tk-73814315991955bca8ffb2c3918830b390c0ac04.tar.bz2 |
Fixed [3512539fff] - .. is silently accepted in widget paths (user: fvogel, tags: bug-3512539fff
-rw-r--r-- | generic/tkWindow.c | 11 | ||||
-rw-r--r-- | tests/window.test | 4 |
2 files changed, 12 insertions, 3 deletions
diff --git a/generic/tkWindow.c b/generic/tkWindow.c index b5cbbab..95e431c 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -1173,10 +1173,12 @@ Tk_CreateWindowFromPath( /* * Strip the parent's name out of pathName (it's everything up to the last - * dot). There are two tricky parts: (a) must copy the parent's name + * dot). There are three tricky parts: (a) must copy the parent's name * somewhere else to avoid modifying the pathName string (for large names, * space for the copy will have to be malloc'ed); (b) must special-case - * the situation where the parent is ".". + * the situation where the parent is "."; (c) the parent's name cannot be + * only 1 character long because it should include both a leading dot and + * at least one additional character. */ p = strrchr(pathName, '.'); @@ -1195,6 +1197,11 @@ Tk_CreateWindowFromPath( if (numChars == 0) { *p = '.'; p[1] = '\0'; + } else if (numChars == 1) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "bad window path name \"%s\"", pathName)); + Tcl_SetErrorCode(interp, "TK", "VALUE", "WINDOW_PATH", NULL); + return NULL; } else { strncpy(p, pathName, (size_t) numChars); p[numChars] = '\0'; diff --git a/tests/window.test b/tests/window.test index fea695a..f02db3e 100644 --- a/tests/window.test +++ b/tests/window.test @@ -39,7 +39,9 @@ test window-1.1 {Tk_CreateWindowFromPath procedure, parent dead} -setup { while executing "button .t.b -text hello" (command bound to event)}} - +test window-1.2 {Tk_CreateWindowFromPath procedure, pathname starting with two dots} -body { + label ..mylabel +} -returnCodes error -result {bad window path name "..mylabel"} # Most of the tests below don't produce meaningful results; they # will simply dump core if there are bugs. |