Thread: BUG #1741: %i missing in snprintf implementation
The following bug has been logged online: Bug reference: 1741 Logged by: Tim Mauch Email address: tgmauch@yahoo.com PostgreSQL version: 8.0.1 - 8.0.3 Operating system: Redhat linux 8.0 Description: %i missing in snprintf implementation Details: The implementation of snprintf/vsnprintf in src/port/snprintf.c does not allow the use of %i ( %d equivalent ). This likely isn't a problem for postgres itself, but when a program compiles with -lpq and the standard c libraries are not previously included the use of %i in the format string of snprintf causes segmentation faults. This is easily fixed by adding "case 'i':" to the same block of code handled by "case 'd':" and case 'D':" in the implementation.
"Tim Mauch" <tgmauch@yahoo.com> writes: > The implementation of snprintf/vsnprintf in src/port/snprintf.c does not > allow the use of %i ( %d equivalent ). This likely isn't a problem for > postgres itself, but when a program compiles with -lpq and the standard c > libraries are not previously included the use of %i in the format string of > snprintf causes segmentation faults. > This is easily fixed by adding "case 'i':" to the same block of code handled > by "case 'd':" and case 'D':" in the implementation. We are certainly not going to buy into the assumption that our snprintf has to support every odd feature that anyone anywhere thinks snprintf should have :-(. The correct response to this is to figure out how your program's calls got linked to our snprintf, and stop that from happening. AFAICS, our library should be defining the global symbol pg_snprintf not snprintf. Can you look into why that's not happening for you? regards, tom lane
Tom Lane wrote: > "Tim Mauch" <tgmauch@yahoo.com> writes: > > The implementation of snprintf/vsnprintf in src/port/snprintf.c does not > > allow the use of %i ( %d equivalent ). This likely isn't a problem for > > postgres itself, but when a program compiles with -lpq and the standard c > > libraries are not previously included the use of %i in the format string of > > snprintf causes segmentation faults. > > This is easily fixed by adding "case 'i':" to the same block of code handled > > by "case 'd':" and case 'D':" in the implementation. > > We are certainly not going to buy into the assumption that our snprintf > has to support every odd feature that anyone anywhere thinks snprintf > should have :-(. The correct response to this is to figure out how your > program's calls got linked to our snprintf, and stop that from > happening. > > AFAICS, our library should be defining the global symbol pg_snprintf not > snprintf. Can you look into why that's not happening for you? Uh, the pg_snprintf macro fix is not in 8.0.X, only 8.1. The good news, however, is that very few platforms used our snprintf in 8.0 (the ones that don't have 64-bit integer support in snprintf). -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073