mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-18 18:44:06 +08:00
Convert possibly-unsafe sprintf's to snprintf's.
This commit is contained in:
parent
b47c4ddc7f
commit
1ccc2451c6
@ -63,13 +63,15 @@ void *
|
||||
BSD44_derived_dlopen(const char *file, int num)
|
||||
{
|
||||
#if defined(__mips__)
|
||||
sprintf(error_message, "dlopen (%s) not supported", file);
|
||||
snprintf(error_message, sizeof(error_message),
|
||||
"dlopen (%s) not supported", file);
|
||||
return NULL;
|
||||
#else
|
||||
void *vp;
|
||||
|
||||
if ((vp = dlopen((char *) file, num)) == (void *) NULL)
|
||||
sprintf(error_message, "dlopen '%s' failed. (%s)", file, dlerror());
|
||||
snprintf(error_message, sizeof(error_message),
|
||||
"dlopen '%s' failed. (%s)", file, dlerror());
|
||||
return vp;
|
||||
#endif
|
||||
}
|
||||
@ -78,7 +80,8 @@ void *
|
||||
BSD44_derived_dlsym(void *handle, const char *name)
|
||||
{
|
||||
#if defined(__mips__)
|
||||
sprintf(error_message, "dlsym (%s) failed", name);
|
||||
snprintf(error_message, sizeof(error_message),
|
||||
"dlsym (%s) failed", name);
|
||||
return NULL;
|
||||
#else
|
||||
void *vp;
|
||||
@ -88,12 +91,13 @@ BSD44_derived_dlsym(void *handle, const char *name)
|
||||
|
||||
if (*name != '_')
|
||||
{
|
||||
sprintf(buf, "_%s", name);
|
||||
snprintf(buf, sizeof(buf), "_%s", name);
|
||||
name = buf;
|
||||
}
|
||||
#endif
|
||||
if ((vp = dlsym(handle, (char *) name)) == (void *) NULL)
|
||||
sprintf(error_message, "dlsym (%s) failed", name);
|
||||
snprintf(error_message, sizeof(error_message),
|
||||
"dlsym (%s) failed", name);
|
||||
return vp;
|
||||
#endif
|
||||
}
|
||||
|
@ -63,13 +63,15 @@ void *
|
||||
BSD44_derived_dlopen(const char *file, int num)
|
||||
{
|
||||
#if defined(__mips__)
|
||||
sprintf(error_message, "dlopen (%s) not supported", file);
|
||||
snprintf(error_message, sizeof(error_message),
|
||||
"dlopen (%s) not supported", file);
|
||||
return NULL;
|
||||
#else
|
||||
void *vp;
|
||||
|
||||
if ((vp = dlopen((char *) file, num)) == (void *) NULL)
|
||||
sprintf(error_message, "dlopen (%s) failed", file);
|
||||
snprintf(error_message, sizeof(error_message),
|
||||
"dlopen (%s) failed", file);
|
||||
return vp;
|
||||
#endif
|
||||
}
|
||||
@ -78,7 +80,8 @@ void *
|
||||
BSD44_derived_dlsym(void *handle, const char *name)
|
||||
{
|
||||
#if defined(__mips__)
|
||||
sprintf(error_message, "dlsym (%s) failed", name);
|
||||
snprintf(error_message, sizeof(error_message),
|
||||
"dlsym (%s) failed", name);
|
||||
return NULL;
|
||||
#elif defined(__ELF__)
|
||||
return dlsym(handle, name);
|
||||
@ -88,11 +91,12 @@ BSD44_derived_dlsym(void *handle, const char *name)
|
||||
|
||||
if (*name != '_')
|
||||
{
|
||||
sprintf(buf, "_%s", name);
|
||||
snprintf(buf, sizeof(buf), "_%s", name);
|
||||
name = buf;
|
||||
}
|
||||
if ((vp = dlsym(handle, (char *) name)) == (void *) NULL)
|
||||
sprintf(error_message, "dlsym (%s) failed", name);
|
||||
snprintf(error_message, sizeof(error_message),
|
||||
"dlsym (%s) failed", name);
|
||||
return vp;
|
||||
#endif
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ next_dlsym(void *handle, char *symbol)
|
||||
char symbuf[1024];
|
||||
unsigned long symref = 0;
|
||||
|
||||
sprintf(symbuf, "_%s", symbol);
|
||||
snprintf(symbuf, sizeof(symbuf), "_%s", symbol);
|
||||
if (!rld_lookup(errorStream, symbuf, &symref))
|
||||
TransferError(errorStream);
|
||||
CloseError(errorStream);
|
||||
|
@ -63,13 +63,15 @@ void *
|
||||
BSD44_derived_dlopen(const char *file, int num)
|
||||
{
|
||||
#if defined(__mips__)
|
||||
sprintf(error_message, "dlopen (%s) not supported", file);
|
||||
snprintf(error_message, sizeof(error_message),
|
||||
"dlopen (%s) not supported", file);
|
||||
return NULL;
|
||||
#else
|
||||
void *vp;
|
||||
|
||||
if ((vp = dlopen((char *) file, num)) == (void *) NULL)
|
||||
sprintf(error_message, "dlopen (%s) failed", file);
|
||||
snprintf(error_message, sizeof(error_message),
|
||||
"dlopen (%s) failed", file);
|
||||
return vp;
|
||||
#endif
|
||||
}
|
||||
@ -78,7 +80,8 @@ void *
|
||||
BSD44_derived_dlsym(void *handle, const char *name)
|
||||
{
|
||||
#if defined(__mips__)
|
||||
sprintf(error_message, "dlsym (%s) failed", name);
|
||||
snprintf(error_message, sizeof(error_message),
|
||||
"dlsym (%s) failed", name);
|
||||
return NULL;
|
||||
#elif defined(__ELF__)
|
||||
return dlsym(handle, name);
|
||||
@ -88,11 +91,12 @@ BSD44_derived_dlsym(void *handle, const char *name)
|
||||
|
||||
if (*name != '_')
|
||||
{
|
||||
sprintf(buf, "_%s", name);
|
||||
snprintf(buf, sizeof(buf), "_%s", name);
|
||||
name = buf;
|
||||
}
|
||||
if ((vp = dlsym(handle, (char *) name)) == (void *) NULL)
|
||||
sprintf(error_message, "dlsym (%s) failed", name);
|
||||
snprintf(error_message, sizeof(error_message),
|
||||
"dlsym (%s) failed", name);
|
||||
return vp;
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user