diff options
author | sr55 <[email protected]> | 2018-06-14 19:56:44 +0100 |
---|---|---|
committer | sr55 <[email protected]> | 2018-06-14 19:56:44 +0100 |
commit | 0c377e599c899845712c22da2d3470df98ab14a7 (patch) | |
tree | 8543e3612e7ec5db154af415c8db7b9490234363 /win/CS/HandBrakeWPF | |
parent | cd533d4ae47317ffef69bcea6ec69d2a711b7798 (diff) |
WinGui: Fix an integer overflow in the UI layer for the start/stop controls. Fixes #1327
Diffstat (limited to 'win/CS/HandBrakeWPF')
-rw-r--r-- | win/CS/HandBrakeWPF/Controls/TimeSpanBox.xaml.cs | 10 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Converters/LongToIntConverter.cs | 34 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/HandBrakeWPF.csproj | 1 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs | 4 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Services/Scan/Model/Title.cs | 2 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 12 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/MainView.xaml | 5 |
7 files changed, 53 insertions, 15 deletions
diff --git a/win/CS/HandBrakeWPF/Controls/TimeSpanBox.xaml.cs b/win/CS/HandBrakeWPF/Controls/TimeSpanBox.xaml.cs index 5f983a699..a8277ec3b 100644 --- a/win/CS/HandBrakeWPF/Controls/TimeSpanBox.xaml.cs +++ b/win/CS/HandBrakeWPF/Controls/TimeSpanBox.xaml.cs @@ -67,7 +67,7 @@ namespace HandBrakeWPF.Controls /// The number property.
/// </summary>
public static readonly DependencyProperty NumberProperty = DependencyProperty.Register(
- "Number", typeof(int), typeof(TimeSpanBox), new PropertyMetadata(OnNumberChanged));
+ "Number", typeof(long), typeof(TimeSpanBox), new PropertyMetadata(OnNumberChanged));
/// <summary>
/// The show time span property.
@@ -225,11 +225,11 @@ namespace HandBrakeWPF.Controls /// <summary>
/// Gets or sets the number.
/// </summary>
- public int Number
+ public long Number
{
get
{
- return (int)this.GetValue(NumberProperty);
+ return (long)this.GetValue(NumberProperty);
}
set
@@ -337,7 +337,7 @@ namespace HandBrakeWPF.Controls /// </summary>
private void DecrementNumber()
{
- int newNumber;
+ long newNumber;
if (this.AllowEmpty && this.Number == 0)
{
newNumber = Math.Min(this.Maximum, -this.Increment);
@@ -416,7 +416,7 @@ namespace HandBrakeWPF.Controls /// </summary>
private void IncrementNumber()
{
- int newNumber;
+ long newNumber;
if (this.AllowEmpty && this.Number == 0)
{
newNumber = Math.Max(this.Minimum, this.Increment);
diff --git a/win/CS/HandBrakeWPF/Converters/LongToIntConverter.cs b/win/CS/HandBrakeWPF/Converters/LongToIntConverter.cs new file mode 100644 index 000000000..97b44338e --- /dev/null +++ b/win/CS/HandBrakeWPF/Converters/LongToIntConverter.cs @@ -0,0 +1,34 @@ +// -------------------------------------------------------------------------------------------------------------------- +// <copyright file="LongToIntConverter.cs" company="HandBrake Project (http://handbrake.fr)"> +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// </copyright> +// <summary> +// Defines the FullPathToFileNameConverter type. +// </summary> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Converters +{ + using System; + using System.Globalization; + using System.Windows.Data; + + public class LongToIntConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null && value is long && (long)value <= int.MaxValue) + { + long result = (long)value; + return (int)result; + } + + return (int)0; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index bbd1fb88d..3fe2ab917 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -132,6 +132,7 @@ <Compile Include="Converters\Filters\DenoisePresetConverter.cs" />
<Compile Include="Converters\Filters\SharpenTuneConverter.cs" />
<Compile Include="Converters\Filters\SharpenPresetConverter.cs" />
+ <Compile Include="Converters\LongToIntConverter.cs" />
<Compile Include="Converters\Options\FileSizeConverter.cs" />
<Compile Include="Converters\Options\LogLevelConverter.cs" />
<Compile Include="Converters\OptionTabConverter.cs" />
diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs index e1f18fd22..c40c6c0b9 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs @@ -184,12 +184,12 @@ namespace HandBrakeWPF.Services.Encode.Model /// <summary> /// Gets or sets StartPoint. /// </summary> - public int StartPoint { get; set; } + public long StartPoint { get; set; } /// <summary> /// Gets or sets EndPoint. /// </summary> - public int EndPoint { get; set; } + public long EndPoint { get; set; } #endregion diff --git a/win/CS/HandBrakeWPF/Services/Scan/Model/Title.cs b/win/CS/HandBrakeWPF/Services/Scan/Model/Title.cs index 31b6a1fe7..144a1ed26 100644 --- a/win/CS/HandBrakeWPF/Services/Scan/Model/Title.cs +++ b/win/CS/HandBrakeWPF/Services/Scan/Model/Title.cs @@ -181,7 +181,7 @@ namespace HandBrakeWPF.Services.Scan.Model /// <param name="startPoint">The Start Point (Chapters)</param> /// <param name="endPoint">The End Point (Chapters)</param> /// <returns>A Timespan</returns> - public TimeSpan CalculateDuration(int startPoint, int endPoint) + public TimeSpan CalculateDuration(long startPoint, long endPoint) { IEnumerable<Chapter> chapers = this.Chapters.Where(c => c.ChapterNumber >= startPoint && c.ChapterNumber <= endPoint); diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 9548fb573..11960ec39 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -811,7 +811,7 @@ namespace HandBrakeWPF.ViewModels {
get
{
- return this.CurrentTask.StartPoint;
+ return this.CurrentTask.Angle;
}
set
@@ -829,12 +829,13 @@ namespace HandBrakeWPF.ViewModels /// <summary>
/// Gets or sets SelectedStartPoint.
/// </summary>
- public int SelectedStartPoint
+ public long SelectedStartPoint
{
get
{
return this.CurrentTask.StartPoint;
}
+
set
{
this.CurrentTask.StartPoint = value;
@@ -860,12 +861,13 @@ namespace HandBrakeWPF.ViewModels /// <summary>
/// Gets or sets SelectedEndPoint.
/// </summary>
- public int SelectedEndPoint
+ public long SelectedEndPoint
{
get
{
return this.CurrentTask.EndPoint;
}
+
set
{
this.CurrentTask.EndPoint = value;
@@ -2306,8 +2308,8 @@ namespace HandBrakeWPF.ViewModels // Update the Main Window
this.NotifyOfPropertyChange(() => this.Destination);
this.SelectedAngle = this.CurrentTask.Angle;
- int start = this.CurrentTask.StartPoint;
- int end = this.CurrentTask.EndPoint;
+ long start = this.CurrentTask.StartPoint;
+ long end = this.CurrentTask.EndPoint;
this.SelectedPointToPoint = this.CurrentTask.PointToPointMode; // Force reset.
this.SelectedStartPoint = start;
this.SelectedEndPoint = end;
diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml index 9a45bfdd5..2bc3929cc 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml @@ -19,6 +19,7 @@ <UserControl.Resources>
<Converters:BooleanConverter x:Key="booleanConverter" />
<Converters:PresetsMenuConverter x:Key="presetsMenuConverter"/>
+ <Converters:LongToIntConverter x:Key="longToIntConverter" />
<Style TargetType="Button">
<Setter Property="Padding" Value="8,2" />
@@ -359,7 +360,7 @@ MinWidth="60"
Margin="5,0,0,0"
ItemsSource="{Binding StartEndRangeItems}"
- SelectedItem="{Binding SelectedStartPoint}"
+ SelectedItem="{Binding SelectedStartPoint, Converter={StaticResource longToIntConverter}}"
ToolTip="{x:Static Properties:ResourcesTooltips.MainView_StartPoint}"
Visibility="{Binding ShowTextEntryForPointToPointMode,
Converter={StaticResource boolToVisConverter},
@@ -376,7 +377,7 @@ MinWidth="60"
Margin="4,0,0,0"
ItemsSource="{Binding StartEndRangeItems}"
- SelectedItem="{Binding SelectedEndPoint}"
+ SelectedItem="{Binding SelectedEndPoint, Converter={StaticResource longToIntConverter}}"
ToolTip="{x:Static Properties:ResourcesTooltips.MainView_EndPoint}"
Visibility="{Binding ShowTextEntryForPointToPointMode,
Converter={StaticResource boolToVisConverter},
|