Bug fix relating to loading of >128-entry partition tables
diff --git a/CHANGELOG b/CHANGELOG
index 5ad500a..1bf0efe 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,15 @@
+0.6.4.1 (2/20/2010):
+--------------------
+
+Note: Neither of the following changes affects actual program code, so I've
+left the version number in the program at 0.6.4.
+
+- Altered Makefile to pass user's compiler and linker environment
+  variables through.
+
+- Added #include to gpttext.cc to enable it to compile on the latest
+  GCC versions (it was failing on at least some 4.4.x compilers).
+
 0.6.4 (2/19/2010):
 -------------------
 
diff --git a/Makefile b/Makefile
index 6554ef3..eda62fe 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,8 @@
 CC=gcc
 CXX=g++
-CFLAGS=-O2 -D_FILE_OFFSET_BITS=64 -g
-CXXFLAGS=-O2 -Wall -D_FILE_OFFSET_BITS=64 -I /usr/local/include -I/opt/local/include -g
+CFLAGS+=-D_FILE_OFFSET_BITS=64
+CXXFLAGS+=-Wall -D_FILE_OFFSET_BITS=64
+LDFLAGS+=
 LIB_NAMES=crc32 support guid gptpart mbr gpt bsd parttypes attributes diskio diskio-unix
 LIB_SRCS=$(NAMES:=.cc)
 LIB_OBJS=$(LIB_NAMES:=.o)
@@ -11,10 +12,10 @@
 all:	gdisk sgdisk
 
 gdisk:	$(LIB_OBJS) gdisk.o gpttext.o
-	$(CXX) $(LIB_OBJS) gdisk.o gpttext.o -L/opt/local/lib -L/usr/local/lib -luuid -o gdisk
+	$(CXX) $(LIB_OBJS) gdisk.o gpttext.o -L/opt/local/lib -L/usr/local/lib $(LDFLAGS) -luuid -o gdisk
 
 sgdisk: $(LIB_OBJS) sgdisk.o
-	$(CXX) $(LIB_OBJS) sgdisk.o -L/opt/local/lib -L/usr/local/lib -luuid -lpopt -o sgdisk
+	$(CXX) $(LIB_OBJS) sgdisk.o -L/opt/local/lib -L/usr/local/lib $(LDFLAGS) -luuid -lpopt -o sgdisk
 
 testguid:	$(LIB_OBJS) testguid.o
 	$(CXX) $(LIB_OBJS) testguid.o -o testguid
diff --git a/gpt.cc b/gpt.cc
index 5ce5b7f..e213205 100644
--- a/gpt.cc
+++ b/gpt.cc
@@ -757,18 +757,24 @@
 // failure.
 int GPTData::LoadHeader(struct GPTHeader *header, DiskIO & disk, uint64_t sector, int *crcOk) {
    int allOK = 1;
+   GPTHeader tempHeader;
 
    disk.Seek(sector);
-   if (disk.Read(header, 512) != 512) {
+   if (disk.Read(&tempHeader, 512) != 512) {
       cerr << "Warning! Read error " << errno << "; strange behavior now likely!\n";
       allOK = 0;
    } // if
-   *crcOk = CheckHeaderCRC(header);
+   *crcOk = CheckHeaderCRC(&tempHeader);
 
-      // Reverse byte order, if necessary
+   // Reverse byte order, if necessary
    if (IsLittleEndian() == 0) {
       ReverseHeaderBytes(header);
    } // if
+
+   if (allOK && mainHeader.numParts != tempHeader.numParts)
+      allOK = SetGPTSize(tempHeader.numParts);
+
+   *header = tempHeader;
    return allOK;
 } // GPTData::LoadHeader
 
diff --git a/gpttext.cc b/gpttext.cc
index f49cab1..3efbdf2 100644
--- a/gpttext.cc
+++ b/gpttext.cc
@@ -24,6 +24,7 @@
 #include <errno.h>
 #include <iostream>
 #include <sstream>
+#include <cstdio>
 #include "attributes.h"
 #include "gpttext.h"
 
@@ -504,4 +505,4 @@
    } while ((typeCode <= 0) || (typeCode > 255));
    cout.fill(' ');
    return typeCode;
-} // GetMBRTypeCode
\ No newline at end of file
+} // GetMBRTypeCode