From 770d26689b855031d262165cca14346fb85710c1 Mon Sep 17 00:00:00 2001
From: Joerg Wunsch <j@uriah.heep.sax.de>
Date: Tue, 3 Sep 2013 11:58:31 +0000
Subject: [PATCH] bug #39691 Buffer overrun when reading EEPROM byte with
 JTAGICE3 * jtag3.c (jtag3_initialize): initialize the eeprom_pagesize private
 attribute so the page cache will actually be usable

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1202 81a1dc3b-b13d-400b-aceb-764788c761c2
---
 ChangeLog | 6 ++++++
 NEWS      | 1 +
 jtag3.c   | 1 +
 3 files changed, 8 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 85cf93f5..6484cfb6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-09-03  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
+
+	bug #39691 Buffer overrun when reading EEPROM byte with JTAGICE3
+	* jtag3.c (jtag3_initialize): initialize the eeprom_pagesize
+	private attribute so the page cache will actually be usable
+
 2013-09-03  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
 
 	bug #38580 Current svn head, xmega and fuses, all fuses tied to fuse0
diff --git a/NEWS b/NEWS
index e88baf4e..fef5093b 100644
--- a/NEWS
+++ b/NEWS
@@ -88,6 +88,7 @@ Current:
       - bug #35800: Compilation error on certain systems if parport is disabled
       - bug #38307: Can't write usersig of an xmega256a3
       - bug #38580 Current svn head, xmega and fuses, all fuses tied to fuse0
+      - bug #39691 Buffer overrun when reading EEPROM byte with JTAGICE3
 
   * Keep track of input file contents
 
diff --git a/jtag3.c b/jtag3.c
index 8724fbc9..f26b64b0 100644
--- a/jtag3.c
+++ b/jtag3.c
@@ -817,6 +817,7 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
         PDATA(pgm)->flash_pagesize = m->page_size;
 	u16_to_b2(xd.flash_page_size, m->page_size);
       } else if (strcmp(m->desc, "eeprom") == 0) {
+	PDATA(pgm)->eeprom_pagesize = m->page_size;
 	xd.eeprom_page_size = m->page_size;
 	u16_to_b2(xd.eeprom_size, m->size);
 	u32_to_b4(xd.nvm_eeprom_offset, m->offset);