@@ -117,7 +117,7 @@ static void writeTime(BCPGOutputStream pOut, long time)
117117 static long readTime (BCPGInputStream in )
118118 throws IOException
119119 {
120- return (long )read4OctetLength (in ) * 1000L ;
120+ return (( long )read4OctetLength (in ) & 0xFFFFFFFFL ) * 1000L ;
121121 }
122122
123123 static void write2OctetLength (OutputStream pOut , int len )
@@ -134,7 +134,7 @@ static int read2OctetLength(InputStream in)
134134 }
135135
136136 static void write4OctetLength (OutputStream pOut , int len )
137- throws IOException
137+ throws IOException
138138 {
139139 pOut .write (len >> 24 );
140140 pOut .write (len >> 16 );
@@ -151,6 +151,7 @@ static int read4OctetLength(InputStream in)
151151 static int flag_eof = 0 ;
152152 static int flag_isLongLength = 1 ;
153153 static int flag_partial = 2 ;
154+
154155 /**
155156 * Note: flags is an array of three boolean values:
156157 * flags[0] indicates l is negative, flag for eof
@@ -191,27 +192,27 @@ else if (l == 255)
191192 static void write8OctetLength (OutputStream pOut , long len )
192193 throws IOException
193194 {
194- pOut .write ((int ) (len >> 56 ));
195- pOut .write ((int ) (len >> 48 ));
196- pOut .write ((int ) (len >> 40 ));
197- pOut .write ((int ) (len >> 32 ));
198- pOut .write ((int ) (len >> 24 ));
199- pOut .write ((int ) (len >> 16 ));
200- pOut .write ((int ) (len >> 8 ));
201- pOut .write ((int ) len );
195+ pOut .write ((int )(len >> 56 ));
196+ pOut .write ((int )(len >> 48 ));
197+ pOut .write ((int )(len >> 40 ));
198+ pOut .write ((int )(len >> 32 ));
199+ pOut .write ((int )(len >> 24 ));
200+ pOut .write ((int )(len >> 16 ));
201+ pOut .write ((int )(len >> 8 ));
202+ pOut .write ((int )len );
202203 }
203204
204205 static long read8OctetLength (InputStream in )
205206 throws IOException
206207 {
207- return ((long ) in .read () << 56 ) |
208- ((long ) in .read () << 48 ) |
209- ((long ) in .read () << 40 ) |
210- ((long ) in .read () << 32 ) |
211- ((long ) in .read () << 24 ) |
212- ((long ) in .read () << 16 ) |
213- ((long ) in .read () << 8 ) |
214- ((long ) in .read ());
208+ return ((long )in .read () << 56 ) |
209+ ((long )in .read () << 48 ) |
210+ ((long )in .read () << 40 ) |
211+ ((long )in .read () << 32 ) |
212+ ((long )in .read () << 24 ) |
213+ ((long )in .read () << 16 ) |
214+ ((long )in .read () << 8 ) |
215+ ((long )in .read ());
215216 }
216217
217218}
0 commit comments