imageinfo fails in Ubuntu 23.04 with a "no such file or directory" error

Bug #2012119 reported by Rocko
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
imageinfo (Ubuntu)
Fix Released
High
Brian Murray

Bug Description

imageinfo fails in Ubuntu 23.04 with a "no such file or directory" error, eg:

$ imageinfo --size /usr/share/backgrounds/Lunar-lobster-side_by_Gixo-dark.png
imageinfo: unable to open image `��s��U': No such file or directory @ error/blob.c/OpenBlob/2924.

$ imageinfo --size /usr/share/backgrounds/Copper_Mountain_by_Eduardo_Battaglia.jpg
imageinfo: unable to open image `�=�V': No such file or directory @ error/blob.c/OpenBlob/2924.

The filename it complains is not found seems to be random and changes each time. Under WSL, it fails but just says "unable to open image `': No such file", ie it doesn't show the random text.

ProblemType: Bug
DistroRelease: Ubuntu 23.04
Package: imageinfo 0.04-0ubuntu12
ProcVersionSignature: Ubuntu 6.1.0-16.16-generic 6.1.6
Uname: Linux 6.1.0-16-generic x86_64
ApportVersion: 2.26.0-0ubuntu2
Architecture: amd64
CasperMD5CheckResult: pass
CurrentDesktop: ubuntu:GNOME
Date: Sat Mar 18 16:31:02 2023
InstallationDate: Installed on 2021-09-28 (536 days ago)
InstallationMedia: Ubuntu 21.10 "Impish Indri" - Beta amd64 (20210924)
ProcEnviron:
 LANG=en_US.UTF-8
 PATH=(custom, no user)
 SHELL=/bin/bash
 TERM=xterm-256color
 XDG_RUNTIME_DIR=<set>
SourcePackage: imageinfo
UpgradeStatus: Upgraded to lunar on 2023-03-16 (1 days ago)

Revision history for this message
Rocko (rockorequin) wrote :
Revision history for this message
Rocko (rockorequin) wrote :

I tried to build imageinfo from source (using apt source imageinfo) but after installing the build-deps (sudo apt build-dep imageinfo) and also the extra package required for Magick-config so configure will succeed, it fails to build with the error "imageinfo.c:373:15: error: ‘Image’ has no member named ‘color_profile’":

$ make
gcc -c imageinfo.c -g -O2 -Wall -DARCH_IS_BIG_ENDIAN=0 -DIMINVERSION=\"0.04\" @MAGICK_CFLAGS@
imageinfo.c: In function ‘main’:
imageinfo.c:99:9: warning: variable ‘orientswitch’ set but not used [-Wunused-but-set-variable]
   99 | float orientswitch = 5.0;
      | ^~~~~~~~~~~~
imageinfo.c: In function ‘signature’:
imageinfo.c:239:9: warning: ‘GetIndexes’ is deprecated [-Wdeprecated-declarations]
  239 | ip = GetIndexes(image);
      | ^~
In file included from /usr/include/magick/enum_strings.h:23,
                 from /usr/include/magick/api.h:84,
                 from imageinfo.c:27:
/usr/include/magick/pixel_cache.h:105:4: note: declared here
  105 | *GetIndexes(const Image *image)
      | ^~~~~~~~~~
imageinfo.c: In function ‘piccmd5’:
imageinfo.c:373:15: error: ‘Image’ has no member named ‘color_profile’
  373 | pi = &(image->color_profile);
      | ^~
make: *** [Makefile:57: imageinfo.o] Error 1

Revision history for this message
Rocko (rockorequin) wrote :

The problem is actually in libpopt. Installing the package from Ubuntu 22.10 (libpopt0_1.18-3build1_amd64.deb, https://packages.ubuntu.com/kinetic/amd64/libpopt0/download) fixes the problem.

Revision history for this message
Rocko (rockorequin) wrote :

Downgrading popt from 1.19+dfsg-1 to 1.18-3build1 shows that the problem is not in imageinfo but in popt.

affects: imageinfo (Ubuntu) → popt (Ubuntu)
Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Thank you for taking the time to file a bug report.

I did some investigation and noticed that the problem is actually with imageinfo.

From imageinfo.c:

  filename = poptGetArg(poptctxt);
  if (poptGetArg(poptctxt) != NULL) {
    fprintf(stderr, "imageinfo: must specify a single filename\n");
    poptFreeContext(poptctxt);
    exit(2);
  }
  poptFreeContext(poptctxt);
  if (!filename) {
    fprintf(stderr, "imageinfo: must specify a filename\n");
    exit(3);
  }

This excerpt is saving a pointer to the the "filename" string that's found inside "poptctxt", but then it calls "poptFreeContext", which will invoke "free" on that same string.

affects: popt (Ubuntu) → imageinfo (Ubuntu)
Changed in imageinfo (Ubuntu):
status: New → Triaged
Revision history for this message
Rocko (rockorequin) wrote (last edit ):

Is this likely to be fixed before 23.04 comes out? I'd patch it myself, but as I mentioned, the source from the repos fails to build (with the error ‘Image’ has no member named ‘color_profile’).

Below is what I did. Am I doing something wrong?

apt source imageinfo
sudo apt build-dep imageinfo
sudo apt install graphicsmagick-libmagick-dev-compat # Need this as well as the build-deps

cd imageinfo-0.04
./configure
make

...

imageinfo.c: In function ‘piccmd5’:
imageinfo.c:373:15: error: ‘Image’ has no member named ‘color_profile’
  373 | pi = &(image->color_profile);
      | ^~
make: *** [Makefile:57: imageinfo.o] Error 1

Revision history for this message
Rocko (rockorequin) wrote :

Anyone?

Revision history for this message
Robie Basak (racb) wrote :

Sorry, it's in our backlog but it seems unlikely it will be prioritised soon.

You need to use "debian/rules build" or "dpkg-buildpackage" to build a Debian source package, since the actual steps to follow can very based on the upstream package, and usually more options are needed to "./configure" etc to reproduce the distribution build exactly. For further help, try asking in #ubuntu-devel on Libera.Chat, or you ask in https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss

Revision history for this message
Rocko (rockorequin) wrote :

Ah, many thanks for the pointer. I ended up building it with "debuild -b -uc -us" to avoid the signing error with dpkg-buildpackage.

I can confirm that removing the poptFreeContext(poptctxt) before using the filename and then adding poptFreeContext(poptctxt) before each exit() call and the return keyword does fix the issue (see attached diff file).

Revision history for this message
Rocko (rockorequin) wrote :

This is a better patch - the last call to poptFreeContext is immediately after the last use of filename.

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "imageinfo.c.diff" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Brian Murray (brian-murray) wrote :

Thanks for the patch Rocko. I'm going to upload this for Ubuntu but looking at the upstream code[1] it still seems to be affected by this issue. Ideally, you'd interact with the upstream developer and get it fixed there too!

[1] https://www.wohlberg.net/public/software/photo/imageinfo/

Changed in imageinfo (Ubuntu):
status: Triaged → In Progress
assignee: nobody → Brian Murray (brian-murray)
importance: Undecided → High
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package imageinfo - 0.04-0ubuntu13

---------------
imageinfo (0.04-0ubuntu13) mantic; urgency=medium

  * Do not prematurely free the filename string. Thanks to Launchpad user
    Rocko for the patch. (LP: #2012119)

 -- Brian Murray <email address hidden> Fri, 11 Aug 2023 13:15:46 -0700

Changed in imageinfo (Ubuntu):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.