Tk Source Code

Check-in [b26fc11e]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix [d4fb4e80d2] - Image photo commands read/write/put do not accept a dash as first letter in file names resp. image data (contributed patch)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | bug-d4fb4e80d2
Files: files | file ages | folders
SHA1: b26fc11eb08a650ffa6d43427a11c79b51f97796
User & Date: fvogel 2016-12-07 20:55:59
References
2016-12-07
21:13
Fix incorrect syntax in test imgPhoto-4.29 that was accepted before the fix [b26fc11eb0] and made the test fail since it's no longer accepted. check-in: c002a972 user: fvogel tags: bug-d4fb4e80d2
Context
2016-12-07
21:13
Fix incorrect syntax in test imgPhoto-4.29 that was accepted before the fix [b26fc11eb0] and made the test fail since it's no longer accepted. check-in: c002a972 user: fvogel tags: bug-d4fb4e80d2
20:55
Fix [d4fb4e80d2] - Image photo commands read/write/put do not accept a dash as first letter in file names resp. image data (contributed patch) check-in: b26fc11e user: fvogel tags: bug-d4fb4e80d2
2016-11-24
09:07
Fix [86a7468862]. Make test combobox-3 pass on all platforms. check-in: eaef25b1 user: jan.nijtmans tags: core-8-6-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tkImgPhoto.c.

809
810
811
812
813
814
815
816
817
818
819
820




821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
	channels[2] = Tcl_NewIntObj(pixelPtr[2]);
	Tcl_SetObjResult(interp, Tcl_NewListObj(3, channels));
	return TCL_OK;
    }

    case PHOTO_PUT:
	/*
	 * photo put command - first parse the options and colors specified.
	 */

	index = 2;
	memset(&options, 0, sizeof(options));




	options.name = NULL;
	if (ParseSubcommandOptions(&options, interp, OPT_TO|OPT_FORMAT,
		&index, objc, objv) != TCL_OK) {
	    return TCL_ERROR;
	}
	if ((options.name == NULL) || (index < objc)) {
	    Tcl_WrongNumArgs(interp, 2, objv, "data ?-option value ...?");
	    return TCL_ERROR;
	}

	if (MatchStringFormat(interp, options.name ? objv[2]:NULL,
		options.format, &imageFormat, &imageWidth,
		&imageHeight, &oldformat) == TCL_OK) {
	    Tcl_Obj *format, *data;

	    if (!(options.options & OPT_TO) || (options.toX2 < 0)) {







|


|

>
>
>
>
|




<
<
<
<







809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829




830
831
832
833
834
835
836
	channels[2] = Tcl_NewIntObj(pixelPtr[2]);
	Tcl_SetObjResult(interp, Tcl_NewListObj(3, channels));
	return TCL_OK;
    }

    case PHOTO_PUT:
	/*
	 * photo put command - first get the image data, then parse the options and colors specified.
	 */

	index = 3;
	memset(&options, 0, sizeof(options));
	if (objc<3) {
	    Tcl_WrongNumArgs(interp, 2, objv, "data ?-option value ...?");
	    return TCL_ERROR;
	}
        options.name = objv[2];
	if (ParseSubcommandOptions(&options, interp, OPT_TO|OPT_FORMAT,
		&index, objc, objv) != TCL_OK) {
	    return TCL_ERROR;
	}





	if (MatchStringFormat(interp, options.name ? objv[2]:NULL,
		options.format, &imageFormat, &imageWidth,
		&imageHeight, &oldformat) == TCL_OK) {
	    Tcl_Obj *format, *data;

	    if (!(options.options & OPT_TO) || (options.toX2 < 0)) {
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007




1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
	ckfree(block.pixelPtr);
	return result;

    case PHOTO_READ: {
	Tcl_Obj *format;

	/*
	 * photo read command - first parse the options specified.
	 */

	index = 2;
	memset(&options, 0, sizeof(options));




	options.name = NULL;
	options.format = NULL;
	if (ParseSubcommandOptions(&options, interp,
		OPT_FORMAT | OPT_FROM | OPT_TO | OPT_SHRINK,
		&index, objc, objv) != TCL_OK) {
	    return TCL_ERROR;
	}
	if ((options.name == NULL) || (index < objc)) {
	    Tcl_WrongNumArgs(interp, 2, objv, "fileName ?-option value ...?");
	    return TCL_ERROR;
	}

	/*
	 * Prevent file system access in safe interpreters.
	 */

	if (Tcl_IsSafe(interp)) {
	    Tcl_SetObjResult(interp, Tcl_NewStringObj(







|


|

>
>
>
>
|
<





<
<
<
<







996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012

1013
1014
1015
1016
1017




1018
1019
1020
1021
1022
1023
1024
	ckfree(block.pixelPtr);
	return result;

    case PHOTO_READ: {
	Tcl_Obj *format;

	/*
	 * photo read command - first get the filename, then parse the options specified.
	 */

	index = 3;
	memset(&options, 0, sizeof(options));
	if (objc < 3) {
	    Tcl_WrongNumArgs(interp, 2, objv, "fileName ?-option value ...?");
	    return TCL_ERROR;
	}
	options.name = objv[2];

	if (ParseSubcommandOptions(&options, interp,
		OPT_FORMAT | OPT_FROM | OPT_TO | OPT_SHRINK,
		&index, objc, objv) != TCL_OK) {
	    return TCL_ERROR;
	}





	/*
	 * Prevent file system access in safe interpreters.
	 */

	if (Tcl_IsSafe(interp)) {
	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299




1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
		    "can't write image to a file in a safe interpreter", -1));
	    Tcl_SetErrorCode(interp, "TK", "SAFE", "PHOTO_FILE", NULL);
	    return TCL_ERROR;
	}

	/*
	 * photo write command - first parse and check any options given.
	 */

	index = 2;
	memset(&options, 0, sizeof(options));




	options.name = NULL;
	options.format = NULL;
	if (ParseSubcommandOptions(&options, interp,
		OPT_FORMAT | OPT_FROM | OPT_GRAYSCALE | OPT_BACKGROUND,
		&index, objc, objv) != TCL_OK) {
	    return TCL_ERROR;
	}
	if ((options.name == NULL) || (index < objc)) {
	    Tcl_WrongNumArgs(interp, 2, objv, "fileName ?-option value ...?");
	    return TCL_ERROR;
	}
	if ((options.fromX > masterPtr->width)
		|| (options.fromY > masterPtr->height)
		|| (options.fromX2 > masterPtr->width)
		|| (options.fromY2 > masterPtr->height)) {
	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
		    "coordinates for -from option extend outside image", -1));
	    Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL);







|


|

>
>
>
>
|
<





<
<
<
<







1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303

1304
1305
1306
1307
1308




1309
1310
1311
1312
1313
1314
1315
	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
		    "can't write image to a file in a safe interpreter", -1));
	    Tcl_SetErrorCode(interp, "TK", "SAFE", "PHOTO_FILE", NULL);
	    return TCL_ERROR;
	}

	/*
	 * photo write command - first get the filename, then parse and check any options given.
	 */

	index = 3;
	memset(&options, 0, sizeof(options));
	if (objc<3) {
	    Tcl_WrongNumArgs(interp, 2, objv, "fileName ?-option value ...?");
	    return TCL_ERROR;
	}
        options.name = objv[2];

	if (ParseSubcommandOptions(&options, interp,
		OPT_FORMAT | OPT_FROM | OPT_GRAYSCALE | OPT_BACKGROUND,
		&index, objc, objv) != TCL_OK) {
	    return TCL_ERROR;
	}




	if ((options.fromX > masterPtr->width)
		|| (options.fromY > masterPtr->height)
		|| (options.fromX2 > masterPtr->width)
		|| (options.fromY2 > masterPtr->height)) {
	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
		    "coordinates for -from option extend outside image", -1));
	    Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL);