Skip to content

Commit

Permalink
better handling for invalid image data;added logging of decrytped req…
Browse files Browse the repository at this point in the history
…uest information
  • Loading branch information
briandunnington committed Jun 8, 2010
1 parent 01da377 commit 87ee9ba
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 18 deletions.
Binary file modified Growl Connectors/NET/libraries/Growl.Connector.dll
Binary file not shown.
Binary file modified Growl Connectors/NET/libraries/Growl.CoreLibrary.dll
Binary file not shown.
Binary file modified Growl Extras/Growl Display SDK/libraries/Growl.CoreLibrary.dll
Binary file not shown.
Binary file modified Growl Extras/Growl Display SDK/libraries/Growl.DisplayStyle.dll
Binary file not shown.
19 changes: 16 additions & 3 deletions Growl/Growl.Daemon/MessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ public class MessageHandler
/// </summary>
private AsyncSocket socket;

/// <summary>
/// The text of the request after decryption (null if the request was not originally encrypted)
/// </summary>
private string decryptedRequest = null;


/// <summary>
/// Type initializer for the MessageHandler class
Expand Down Expand Up @@ -935,6 +940,13 @@ public void Log(Data data)
}
w.Write(SEPERATOR);
w.Write(this.alreadyReceived.ToString());

if (!String.IsNullOrEmpty(this.decryptedRequest))
{
w.Write(SEPERATOR);
w.Write(this.decryptedRequest);
}

w.Write(SEPERATOR);
w.Write(data.ToString());
w.Close();
Expand Down Expand Up @@ -1190,11 +1202,12 @@ private void ParseEncryptedMessage(byte[] bytes)
}
Buffer.BlockCopy(bytes, 0, encryptedBytes, 0, encryptedBytes.Length);

//byte[] encryptionKey = this.key.GetEncryptionKey(this.keyHashAlgorithm);
//byte[] decryptedBytes = Cryptography.Decrypt(encryptionKey, this.iv, encryptedBytes, this.encryptionAlgorithm);
byte[] decryptedBytes = this.key.Decrypt(encryptedBytes, this.iv);

string x = Encoding.UTF8.GetString(decryptedBytes);
// log the decrypted data
#if DEBUG
this.decryptedRequest = Encoding.UTF8.GetString(decryptedBytes);
#endif

System.IO.MemoryStream stream = new System.IO.MemoryStream(decryptedBytes);
using (stream)
Expand Down
2 changes: 2 additions & 0 deletions Growl/Growl/_source/ApplicationMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ internal enum Signal
[STAThread()]
static void Main(string[] args)
{
#if DEBUG
//System.Diagnostics.Debugger.Launch();
#endif

try
{
Expand Down
37 changes: 22 additions & 15 deletions Growl/Growl/_source/PastNotificationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,15 @@ public static PastNotification Save(Growl.DisplayStyle.Notification notification
using (image)
{
System.Drawing.Image thumbnail = GenerateThumbnail(image, 48, 48);
using (thumbnail)
if (thumbnail != null)
{
string imagefilename = String.Format(@"{0}.img", requestID);
imageFile = Growl.CoreLibrary.PathUtility.Combine(path, imagefilename);
using (thumbnail)
{
string imagefilename = String.Format(@"{0}.img", requestID);
imageFile = Growl.CoreLibrary.PathUtility.Combine(path, imagefilename);

thumbnail.Save(imageFile);
thumbnail.Save(imageFile);
}
}
}
}
Expand Down Expand Up @@ -181,21 +184,25 @@ public static Image GetImage(PastNotification pn)

private static System.Drawing.Image GenerateThumbnail(System.Drawing.Image originalImage, int newWidth, int newHeight)
{
System.Drawing.Bitmap bmpResized = new System.Drawing.Bitmap(newWidth, newHeight);
lock (bmpResized)
if (originalImage != null)
{
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmpResized);
using (g)
System.Drawing.Bitmap bmpResized = new System.Drawing.Bitmap(newWidth, newHeight);
lock (bmpResized)
{
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default;
g.DrawImage(
originalImage,
new System.Drawing.Rectangle(System.Drawing.Point.Empty, bmpResized.Size),
new System.Drawing.Rectangle(System.Drawing.Point.Empty, originalImage.Size),
System.Drawing.GraphicsUnit.Pixel);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmpResized);
using (g)
{
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default;
g.DrawImage(
originalImage,
new System.Drawing.Rectangle(System.Drawing.Point.Empty, bmpResized.Size),
new System.Drawing.Rectangle(System.Drawing.Point.Empty, originalImage.Size),
System.Drawing.GraphicsUnit.Pixel);
}
}
return bmpResized;
}
return bmpResized;
return null;
}
}
}

0 comments on commit 87ee9ba

Please sign in to comment.