cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Pilgrim

Change of behaviour of SprintfMsiLog between IS 2013 and IS 2015 on Vista

Hi there,

Better late than never, we have just upgraded our projects from IS 2013 to IS 2015.
We bumped into a little issue with SprintfMsiLog.

Something must have changed in IS 2015 (or maybe already in IS 2014), as our installation packages no longer worked on Vista after we upgraded.

Here we go:

  • We've got a Basic MSI project, with quite a few CustomActions of type InstallScript.
  • One of them logs quite a lot of information to the Msi log file using SprintfMsiLog.

One of the calls of SprintMsiLog was like that:
SprintfMsiLog( "********************* " + szTitle + ": " + szMessage );

It used to work fine when built with IS 2013, whatever szTitle and szMessage contained.

Once we started to build this project with IS 2015 and test it on various OS, the code above would abort the CustomAction and make the whole installation fail under Windows Vista (and only Vista!).

After quite a few trials and errors, I realized what conditions made it fail:
if either szTitle or szMessage contained a percent sign, the code above would fail if the project was built with IS 2015.

Changing the code to:
SprintfMsiLog( "********************* %s: %s", szTitle, szMessage );

resolved the problem.

So here are my questions:

  • Did you guys change the InstallScript implementation of SprintfMsiLog in either IS 2014 or in IS 2015 ?
  • Is this change documented anywhere?
  • Last but not least, any idea why it only fails on Vista?


Thanks for reading!
Labels (1)
0 Kudos
2 Replies
Highlighted
Flexera
Flexera

Re: Change of behaviour of SprintfMsiLog between IS 2013 and IS 2015 on Vista

There weren't any explicit changes to SprintfMsiLog with any recent release of InstallShield, going back well before IS 2013. However, between 2013 and 2015, the compiler used to build the InstallScript engine was updated to a newer version. This is the only likely reason for the change in behavior, as changing the compiler brings a new version of the C and C++ runtime libraries, along with subtle changes in memory layout and usage.

The root issue here is the invalid usage of formatting specifiers. Since the first parameter to SprintfMsiLog is a format string that accepts printf style format specifiers, care must be taken to ensure any use of '%' characters is valid, either as valid format specifiers or an escaped '%' character ('%%'). Any invalid use of formatting specifiers will likely result in the format handling in the C runtime library crashing (try passing the same string in a native C/C++ application to printf or sprintf and notice the runtime behavior).

The change you made to use '%s' for the variable arguments to the string is the easiest solution as this avoids have to replace '%' characters with correctly escaped ones.
0 Kudos
Highlighted
Pilgrim

Re: Change of behaviour of SprintfMsiLog between IS 2013 and IS 2015 on Vista

Hi Josh,

Thanks for your reply.
I understood what the root cause was and it was easy to resolve, but you probably understood why I got a bit surprised to see it fail only on Vista.

But yes, this error in my code suddenly being revealed might well be related to the new runtime libraries. I would have thought that these libraries would work in the same way on Vista as on other OS's though.

Best regards,
Reureu
0 Kudos