|
|
13bb5b |
From daf661fbffb3e4c6afd082785721f199f992eab0 Mon Sep 17 00:00:00 2001
|
|
|
13bb5b |
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
|
|
13bb5b |
Date: Wed, 4 Jun 2014 16:26:06 +0200
|
|
|
13bb5b |
Subject: [PATCH] screenshot: Also validate parameters to FlashArea()
|
|
|
13bb5b |
|
|
|
13bb5b |
Apply the same parameter validation to FlashArea() we already use
|
|
|
13bb5b |
for ScreenshotArea().
|
|
|
13bb5b |
|
|
|
13bb5b |
https://bugzilla.gnome.org/show_bug.cgi?id=731220
|
|
|
13bb5b |
---
|
|
|
13bb5b |
js/ui/screenshot.js | 26 ++++++++++++++++++++------
|
|
|
13bb5b |
1 file changed, 20 insertions(+), 6 deletions(-)
|
|
|
13bb5b |
|
|
|
13bb5b |
diff --git a/js/ui/screenshot.js b/js/ui/screenshot.js
|
|
|
13bb5b |
index 3c5c831..f85c62e 100644
|
|
|
13bb5b |
--- a/js/ui/screenshot.js
|
|
|
13bb5b |
+++ b/js/ui/screenshot.js
|
|
|
13bb5b |
@@ -64,6 +64,13 @@ const ScreenshotService = new Lang.Class({
|
|
|
13bb5b |
Gio.DBus.session.own_name('org.gnome.Shell.Screenshot', Gio.BusNameOwnerFlags.REPLACE, null, null);
|
|
|
13bb5b |
},
|
|
|
13bb5b |
|
|
|
13bb5b |
+ _checkArea: function(x, y, width, height) {
|
|
|
13bb5b |
+ return x >= 0 && y >= 0 &&
|
|
|
13bb5b |
+ width > 0 && height > 0 &&
|
|
|
13bb5b |
+ x + width <= global.screen_width &&
|
|
|
13bb5b |
+ y + height <= global.screen_height;
|
|
|
13bb5b |
+ },
|
|
|
13bb5b |
+
|
|
|
13bb5b |
_onScreenshotComplete: function(obj, result, area, filenameUsed, flash, invocation) {
|
|
|
13bb5b |
if (flash && result) {
|
|
|
13bb5b |
let flashspot = new Flashspot(area);
|
|
|
13bb5b |
@@ -76,11 +83,10 @@ const ScreenshotService = new Lang.Class({
|
|
|
13bb5b |
|
|
|
13bb5b |
ScreenshotAreaAsync : function (params, invocation) {
|
|
|
13bb5b |
let [x, y, width, height, flash, filename, callback] = params;
|
|
|
13bb5b |
- if (x < 0 || y < 0 ||
|
|
|
13bb5b |
- width <= 0 || height <= 0 ||
|
|
|
13bb5b |
- x + width > global.screen_width || y + height > global.screen_height) {
|
|
|
13bb5b |
- invocation.return_error_literal(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED,
|
|
|
13bb5b |
- "Invalid params");
|
|
|
13bb5b |
+ if (!this._checkArea(x, y, width, height)) {
|
|
|
13bb5b |
+ invocation.return_error_literal(Gio.IOErrorEnum,
|
|
|
13bb5b |
+ Gio.IOErrorEnum.CANCELLED,
|
|
|
13bb5b |
+ "Invalid params");
|
|
|
13bb5b |
return;
|
|
|
13bb5b |
}
|
|
|
13bb5b |
let screenshot = new Shell.Screenshot();
|
|
|
13bb5b |
@@ -122,9 +128,17 @@ const ScreenshotService = new Lang.Class({
|
|
|
13bb5b |
}));
|
|
|
13bb5b |
},
|
|
|
13bb5b |
|
|
|
13bb5b |
- FlashArea: function(x, y, width, height) {
|
|
|
13bb5b |
+ FlashAreaAsync: function(params, invocation) {
|
|
|
13bb5b |
+ let [x, y, width, height] = params;
|
|
|
13bb5b |
+ if (!this._checkArea(x, y, width, height)) {
|
|
|
13bb5b |
+ invocation.return_error_literal(Gio.IOErrorEnum,
|
|
|
13bb5b |
+ Gio.IOErrorEnum.CANCELLED,
|
|
|
13bb5b |
+ "Invalid params");
|
|
|
13bb5b |
+ return;
|
|
|
13bb5b |
+ }
|
|
|
13bb5b |
let flashspot = new Flashspot({ x : x, y : y, width: width, height: height});
|
|
|
13bb5b |
flashspot.fire();
|
|
|
13bb5b |
+ invocation.return_value(null);
|
|
|
13bb5b |
}
|
|
|
13bb5b |
});
|
|
|
13bb5b |
|
|
|
13bb5b |
--
|
|
|
13bb5b |
2.1.0
|
|
|
13bb5b |
|