hadoop-zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ph...@apache.org
Subject svn commit: r706718 - in /hadoop/zookeeper/trunk: CHANGES.txt src/java/main/org/apache/zookeeper/server/persistence/FileSnap.java src/java/main/org/apache/zookeeper/server/persistence/FileTxnLog.java
Date Tue, 21 Oct 2008 18:45:21 GMT
Author: phunt
Date: Tue Oct 21 11:45:20 2008
New Revision: 706718

URL: http://svn.apache.org/viewvc?rev=706718&view=rev
Log:
ZOOKEEPER-201. validate magic number when reading snapshot and transaction

Modified:
    hadoop/zookeeper/trunk/CHANGES.txt
    hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/persistence/FileSnap.java
    hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/persistence/FileTxnLog.java

Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=706718&r1=706717&r2=706718&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Tue Oct 21 11:45:20 2008
@@ -35,6 +35,9 @@
 
   BUGFIXES: 
 
+  ZOOKEEPER-201. validate magic number when reading snapshot and transaction
+  logs (mahadev via phunt)
+
   ZOOKEEPER-200. the magic number for snapshot and log must be different
   (currently same) (phunt)
 

Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/persistence/FileSnap.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/persistence/FileSnap.java?rev=706718&r1=706717&r2=706718&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/persistence/FileSnap.java
(original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/persistence/FileSnap.java
Tue Oct 21 11:45:20 2008
@@ -94,6 +94,11 @@
             InputArchive ia) throws IOException {
         FileHeader header = new FileHeader();
         header.deserialize(ia, "fileheader");
+        if (header.getMagic() != SNAP_MAGIC) {
+            throw new IOException("mismatching magic headers "
+                    + header.getMagic() + 
+                    " !=  " + FileSnap.SNAP_MAGIC);
+        }
         SerializeUtils.deserializeSnapshot(dt,ia,sessions);
     }
 

Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/persistence/FileTxnLog.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/persistence/FileTxnLog.java?rev=706718&r1=706717&r2=706718&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/persistence/FileTxnLog.java
(original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/persistence/FileTxnLog.java
Tue Oct 21 11:45:20 2008
@@ -384,6 +384,10 @@
             throws IOException{
             FileHeader header= new FileHeader();
             header.deserialize(ia, "fileheader");
+            if (header.getMagic() != FileTxnLog.TXNLOG_MAGIC) {
+                throw new IOException("Invalid magic number " + header.getMagic() 
+                        + " != " + FileTxnLog.TXNLOG_MAGIC);
+            }  
         }
         
         /**
@@ -395,10 +399,10 @@
         protected InputArchive createInputArchive(File logFile) throws IOException {
             if(inputStream==null){
                 inputStream= new FileInputStream(logFile);
-                LOG.info("Created new input stream " + logFile);
+                LOG.debug("Created new input stream " + logFile);
                 ia  = BinaryInputArchive.getArchive(new BufferedInputStream(inputStream));
                 inStreamCreated(ia,inputStream);
-                LOG.info("created new input archive " + logFile);
+                LOG.debug("created new input archive " + logFile);
             }
             return ia;
         }



Mime
View raw message