X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fextract.c;h=092c8c4033a26659ee270ddf406d5d63d328bd1a;hb=2b04e3ff551654916caba6f6fad50908de67b0fd;hp=95071bd7bfbb35b45dec106755a88b1c0db204e8;hpb=e7302af311839d06f6faf4192d2d0eae6d895b2a;p=wimlib diff --git a/src/extract.c b/src/extract.c index 95071bd7..092c8c40 100644 --- a/src/extract.c +++ b/src/extract.c @@ -2629,16 +2629,26 @@ wimlib_extract_image_from_pipe(int pipe_fd, const tchar *image_num_or_name, /* Get image index (this may use the XML data that was just read to * resolve an image name). */ - image = wimlib_resolve_image(pwm, image_num_or_name); - if (image == WIMLIB_NO_IMAGE) { - ERROR("\"%"TS"\" is not a valid image in the pipable WIM!", - image_num_or_name); - ret = WIMLIB_ERR_INVALID_IMAGE; - goto out_wimlib_free; - } else if (image == WIMLIB_ALL_IMAGES) { - ERROR("Applying all images from a pipe is not supported."); - ret = WIMLIB_ERR_INVALID_IMAGE; - goto out_wimlib_free; + if (image_num_or_name) { + image = wimlib_resolve_image(pwm, image_num_or_name); + if (image == WIMLIB_NO_IMAGE) { + ERROR("\"%"TS"\" is not a valid image in the pipable WIM!", + image_num_or_name); + ret = WIMLIB_ERR_INVALID_IMAGE; + goto out_wimlib_free; + } else if (image == WIMLIB_ALL_IMAGES) { + ERROR("Applying all images from a pipe is not supported."); + ret = WIMLIB_ERR_INVALID_IMAGE; + goto out_wimlib_free; + } + } else { + if (pwm->hdr.image_count != 1) { + ERROR("No image was specified, but the pipable WIM " + "did not contain exactly 1 image"); + ret = WIMLIB_ERR_INVALID_IMAGE; + goto out_wimlib_free; + } + image = 1; } /* Load the needed metadata resource. */