diff --git a/sm5/CHANGELOG b/sm5/CHANGELOG
index 3b005fe91aacf72ddd53ac4d8fa02975ce672f36..805c3b3d64b9cb7df441b46510ab6b680112c758 100644
--- a/sm5/CHANGELOG
+++ b/sm5/CHANGELOG
@@ -1,6 +1,6 @@
 CHANGELOG for smartmontools
 
-$Id: CHANGELOG,v 1.55 2002/11/22 13:37:42 ballen4705 Exp $
+$Id: CHANGELOG,v 1.56 2002/11/22 16:26:45 ballen4705 Exp $
 
 Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net>
 
@@ -25,6 +25,9 @@ NOTES FOR FUTURE RELEASES: see TODO file.
 
 CURRENT RELEASE (see VERSION file in this directory):
 
+  Allen: smartctl.  When raw Attribute value was 2^31 or larger, did
+  not print correctly.
+
 smartmontools-5.0.46
 
   Allen: smartd: added smartd.conf Directives -T and -s.  The -T Directive
diff --git a/sm5/VERSION b/sm5/VERSION
index 9e5feb5256930f3cae636754eef8a244ede164eb..abac1ea7b759d8258c9ad9e5b450f782aaa33374 100644
--- a/sm5/VERSION
+++ b/sm5/VERSION
@@ -1 +1 @@
-46
+47
diff --git a/sm5/ataprint.c b/sm5/ataprint.c
index 5a2fb37ad6bff0f08cec79ed156d1fdf8d23eef0..08e02549c0344b213b942705d02d7e2be25bb23c 100644
--- a/sm5/ataprint.c
+++ b/sm5/ataprint.c
@@ -30,7 +30,7 @@
 #include "smartctl.h"
 #include "extern.h"
 
-const char *CVSid2="$Id: ataprint.c,v 1.44 2002/11/14 14:57:20 ballen4705 Exp $"
+const char *CVSid2="$Id: ataprint.c,v 1.45 2002/11/22 16:26:46 ballen4705 Exp $"
 CVSID1 CVSID2 CVSID3 CVSID6;
 
 // for passing global control variables
@@ -416,9 +416,17 @@ void PrintSmartAttribWithThres (struct ata_smart_values *data,
       
       // convert the six individual bytes to a long long (8 byte) integer
       rawvalue = 0;
-      for (j = 0 ; j < 6 ; j++)
-	rawvalue |= disk->raw[j] << (8*j) ;
-      
+      for (j=0; j<6; j++) {
+	// This looks a bit roundabout, but is necessary.  Don't
+	// succumb to the temptation to use raw[j]<<(8*j) since under
+	// the normal rules this will be promoted to the native type.
+	// On a 32 bit machine this might then overflow.
+	long long temp;
+	temp = disk->raw[j];
+	temp <<= 8*j;
+	rawvalue |= temp;
+      }
+
       // This switch statement is where we handle Raw attributes
       // that are stored in an unusual vendor-specific format,
       switch (disk->id){
diff --git a/sm5/ataprint.cpp b/sm5/ataprint.cpp
index eac4d660d4a43cdddc9366bd12dbd1c7f72fe313..e15b5240315311423f463c12f69de620c14f5a1d 100644
--- a/sm5/ataprint.cpp
+++ b/sm5/ataprint.cpp
@@ -30,7 +30,7 @@
 #include "smartctl.h"
 #include "extern.h"
 
-const char *CVSid2="$Id: ataprint.cpp,v 1.44 2002/11/14 14:57:20 ballen4705 Exp $"
+const char *CVSid2="$Id: ataprint.cpp,v 1.45 2002/11/22 16:26:46 ballen4705 Exp $"
 CVSID1 CVSID2 CVSID3 CVSID6;
 
 // for passing global control variables
@@ -416,9 +416,17 @@ void PrintSmartAttribWithThres (struct ata_smart_values *data,
       
       // convert the six individual bytes to a long long (8 byte) integer
       rawvalue = 0;
-      for (j = 0 ; j < 6 ; j++)
-	rawvalue |= disk->raw[j] << (8*j) ;
-      
+      for (j=0; j<6; j++) {
+	// This looks a bit roundabout, but is necessary.  Don't
+	// succumb to the temptation to use raw[j]<<(8*j) since under
+	// the normal rules this will be promoted to the native type.
+	// On a 32 bit machine this might then overflow.
+	long long temp;
+	temp = disk->raw[j];
+	temp <<= 8*j;
+	rawvalue |= temp;
+      }
+
       // This switch statement is where we handle Raw attributes
       // that are stored in an unusual vendor-specific format,
       switch (disk->id){