Package org.eclipse.jgit.errors

Examples of org.eclipse.jgit.errors.CorruptObjectException


    }

    try {
      return BinaryDelta.getResultSize(getDeltaHeader(curs, deltaAt));
    } catch (DataFormatException e) {
      throw new CorruptObjectException(MessageFormat.format(JGitText
          .get().objectAtHasBadZlibStream, pos, getPackFile()));
    }
  }
View Full Code Here


              use(bAvail);

              p = fill(src, 1);
              inf.setInput(buf, p, bAvail);
            } else {
              throw new CorruptObjectException(
                  MessageFormat
                      .format(
                          JGitText.get().packfileCorruptionDetected,
                          JGitText.get().unknownZlibError));
            }
          } else {
            n += r;
          }
        }
        actualSize += n;
        return 0 < n ? n : -1;
      } catch (DataFormatException dfe) {
        throw new CorruptObjectException(MessageFormat.format(JGitText
            .get().packfileCorruptionDetected, dfe.getMessage()));
      }
    }
View Full Code Here

      // We need to read here to enter the loop above and pump the
      // trailing checksum into the Inflater. It should return -1 as the
      // caller was supposed to consume all content.
      //
      if (read(skipBuffer) != -1 || actualSize != expectedSize) {
        throw new CorruptObjectException(MessageFormat.format(JGitText
            .get().packfileCorruptionDetected,
            JGitText.get().wrongDecompressedLength));
      }

      int used = bAvail - inf.getRemaining();
View Full Code Here

        in.reset();
        Inflater inf = wc.inflater();
        InputStream zIn = inflate(in, inf);
        int avail = readSome(zIn, hdr, 0, 64);
        if (avail < 5)
          throw new CorruptObjectException(id,
              JGitText.get().corruptObjectNoHeader);

        final MutableInteger p = new MutableInteger();
        int type = Constants.decodeTypeString(id, hdr, (byte) ' ', p);
        long size = RawParseUtils.parseLongBase10(hdr, p.value, p);
        if (size < 0)
          throw new CorruptObjectException(id,
              JGitText.get().corruptObjectNegativeSize);
        if (hdr[p.value++] != 0)
          throw new CorruptObjectException(id,
              JGitText.get().corruptObjectGarbageAfterSize);
        if (path == null && Integer.MAX_VALUE < size) {
          LargeObjectException.ExceedsByteArrayLimit e;
          e = new LargeObjectException.ExceedsByteArrayLimit();
          e.setObjectId(id);
          throw e;
        }
        if (size < wc.getStreamFileThreshold() || path == null) {
          byte[] data = new byte[(int) size];
          int n = avail - p.value;
          if (n > 0)
            System.arraycopy(hdr, p.value, data, 0, n);
          IO.readFully(zIn, data, n, data.length - n);
          checkValidEndOfStream(in, inf, id, hdr);
          return new ObjectLoader.SmallObject(type, data);
        }
        return new LargeObject(type, size, path, id, wc.db);

      } else {
        readSome(in, hdr, 2, 18);
        int c = hdr[0] & 0xff;
        int type = (c >> 4) & 7;
        long size = c & 15;
        int shift = 4;
        int p = 1;
        while ((c & 0x80) != 0) {
          c = hdr[p++] & 0xff;
          size += (c & 0x7f) << shift;
          shift += 7;
        }

        switch (type) {
        case Constants.OBJ_COMMIT:
        case Constants.OBJ_TREE:
        case Constants.OBJ_BLOB:
        case Constants.OBJ_TAG:
          // Acceptable types for a loose object.
          break;
        default:
          throw new CorruptObjectException(id,
              JGitText.get().corruptObjectInvalidType);
        }

        if (path == null && Integer.MAX_VALUE < size) {
          LargeObjectException.ExceedsByteArrayLimit e;
          e = new LargeObjectException.ExceedsByteArrayLimit();
          e.setObjectId(id);
          throw e;
        }
        if (size < wc.getStreamFileThreshold() || path == null) {
          in.reset();
          IO.skipFully(in, p);
          Inflater inf = wc.inflater();
          InputStream zIn = inflate(in, inf);
          byte[] data = new byte[(int) size];
          IO.readFully(zIn, data, 0, data.length);
          checkValidEndOfStream(in, inf, id, hdr);
          return new ObjectLoader.SmallObject(type, data);
        }
        return new LargeObject(type, size, path, id, wc.db);
      }
    } catch (ZipException badStream) {
      throw new CorruptObjectException(id,
          JGitText.get().corruptObjectBadStream);
    }
  }
View Full Code Here

        in.reset();
        Inflater inf = wc.inflater();
        InputStream zIn = inflate(in, inf);
        int avail = readSome(zIn, hdr, 0, 64);
        if (avail < 5)
          throw new CorruptObjectException(id,
              JGitText.get().corruptObjectNoHeader);

        final MutableInteger p = new MutableInteger();
        Constants.decodeTypeString(id, hdr, (byte) ' ', p);
        long size = RawParseUtils.parseLongBase10(hdr, p.value, p);
        if (size < 0)
          throw new CorruptObjectException(id,
              JGitText.get().corruptObjectNegativeSize);
        return size;

      } else {
        readSome(in, hdr, 2, 18);
        int c = hdr[0] & 0xff;
        long size = c & 15;
        int shift = 4;
        int p = 1;
        while ((c & 0x80) != 0) {
          c = hdr[p++] & 0xff;
          size += (c & 0x7f) << shift;
          shift += 7;
        }
        return size;
      }
    } catch (ZipException badStream) {
      throw new CorruptObjectException(id,
          JGitText.get().corruptObjectBadStream);
    }
  }
View Full Code Here

    for (;;) {
      int r;
      try {
        r = inf.inflate(buf);
      } catch (DataFormatException e) {
        throw new CorruptObjectException(id,
            JGitText.get().corruptObjectBadStream);
      }
      if (r != 0)
        throw new CorruptObjectException(id,
            JGitText.get().corruptObjectIncorrectLength);

      if (inf.finished()) {
        if (inf.getRemaining() != 0 || in.read() != -1)
          throw new CorruptObjectException(id,
              JGitText.get().corruptObjectBadStream);
        break;
      }

      if (!inf.needsInput())
        throw new CorruptObjectException(id,
            JGitText.get().corruptObjectBadStream);

      r = in.read(buf);
      if (r <= 0)
        throw new CorruptObjectException(id,
            JGitText.get().corruptObjectBadStream);
      inf.setInput(buf, 0, r);
    }
  }
View Full Code Here

          int r = super.read(b, off, cnt);
          if (r > 0)
            remaining -= r;
          return r;
        } catch (ZipException badStream) {
          throw new CorruptObjectException(id,
              JGitText.get().corruptObjectBadStream);
        }
      }

      @Override
View Full Code Here

    final byte[] srcHash = new byte[20];
    System.arraycopy(buf, c, srcHash, 0, 20);
    use(20);

    if (!Arrays.equals(actHash, srcHash))
      throw new CorruptObjectException(
          JGitText.get().corruptObjectPackfileChecksumIncorrect);

    onPackFooter(srcHash);
  }
View Full Code Here

        break;

      case CMD_EOF:
        return act;
      default:
        throw new CorruptObjectException(
            JGitText.get().unsupportedCommand0);
      }

      act += n;
      len -= n;
View Full Code Here

      switch (curcmd) {
      case CMD_COPY:
        seekBase();
        n = baseStream.read(buf, off, n);
        if (n < 0)
          throw new CorruptObjectException(
              JGitText.get().baseLengthIncorrect);
        copyOffset += n;
        baseOffset = copyOffset;
        break;

      case CMD_INSERT:
        System.arraycopy(cmdbuf, cmdptr, buf, off, n);
        cmdptr += n;
        break;

      case CMD_EOF:
        return 0 < act ? act : -1;

      default:
        throw new CorruptObjectException(
            JGitText.get().unsupportedCommand0);
      }

      act += n;
      off += n;
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.errors.CorruptObjectException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.