Skip to content

Commit

Permalink
OS-4493 'imgadm import bbytes/proxy-etc' crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
trentm committed Jul 8, 2015
1 parent ca205d6 commit 60ff895
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 16 deletions.
4 changes: 4 additions & 0 deletions src/img/CHANGES.md
@@ -1,5 +1,9 @@
# imgadm changelog

## 3.5.2

- OS-4493 Fix an 'imgadm import' crash on invalid Docker image ancestry info.

## 3.5.1

- OS-4466 Fix an issue where some Docker images could not be imported because
Expand Down
15 changes: 15 additions & 0 deletions src/img/lib/errors.js
Expand Up @@ -489,6 +489,20 @@ function InvalidUUIDError(cause, uuid) {
}
util.inherits(InvalidUUIDError, ImgadmError);

function InvalidDockerInfoError(cause, message) {
if (message === undefined) {
message = cause;
cause = undefined;
}
ImgadmError.call(this, {
cause: cause,
message: message,
code: 'InvalidDockerInfo',
exitStatus: 1
});
}
util.inherits(InvalidDockerInfoError, ImgadmError);

function InvalidArgumentError(cause, message) {
if (message === undefined) {
message = cause;
Expand Down Expand Up @@ -772,6 +786,7 @@ module.exports = {
ImgadmError: ImgadmError,
InternalError: InternalError,
InvalidUUIDError: InvalidUUIDError,
InvalidDockerInfoError: InvalidDockerInfoError,
InvalidArgumentError: InvalidArgumentError,
MinPlatformError: MinPlatformError,
MaxPlatformError: MaxPlatformError,
Expand Down
24 changes: 17 additions & 7 deletions src/img/lib/sources/docker.js
Expand Up @@ -191,16 +191,26 @@ DockerSource.prototype.getImgAncestry = function getImgAncestry(opts, cb) {
cb(err);
return;
}
var ancestry = dAncestry.map(function (imgId) {
return {
imgId: imgId,
uuid: imgmanifest.imgUuidFromDockerInfo({
var ancestry = [];
for (var i = 0; i < dAncestry.length; i++) {
var imgId = dAncestry[i];
try {
var uuid = imgmanifest.imgUuidFromDockerInfo({
id: imgId,
indexName: opts.repo.index.name
}),
});
} catch (infoErr) {
return cb(new errors.InvalidDockerInfoError(
infoErr, format('docker image %s\'s ancestry (repo %s) ' +
'includes invalid info: %s', opts.imgId,
opts.repo.localName, infoErr.message)));
}
ancestry.push({
imgId: imgId,
uuid: uuid,
repo: opts.repo
};
});
});
}
cb(null, ancestry);
});
};
Expand Down
9 changes: 7 additions & 2 deletions src/img/node_modules/imgmanifest/lib/imgmanifest.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/img/node_modules/imgmanifest/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/img/package.json
@@ -1,7 +1,7 @@
{
"name": "imgadm",
"description": "Manage SmartOS virtual machine images.",
"version": "3.5.1",
"version": "3.5.2",
"author": "Joyent (joyent.com)",
"private": true,
"dependencies": {
Expand All @@ -13,7 +13,7 @@
"docker-registry-client": "git://github.com/joyent/node-docker-registry-client.git#765e74c",
"extsprintf": "1.2.0",
"findit": "2.0.0",
"imgmanifest": "git://github.com/joyent/node-imgmanifest.git#7dda1e5",
"imgmanifest": "git://github.com/joyent/node-imgmanifest.git#158e617",
"mkdirp": "0.5.0",
"node-uuid": "1.4.1",
"once": "1.3.1",
Expand Down

0 comments on commit 60ff895

Please sign in to comment.