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)
|
BSD44_derived_dlopen(const char *file, int num)
|
||||||
{
|
{
|
||||||
#if defined(__mips__)
|
#if defined(__mips__)
|
||||||
sprintf(error_message, "dlopen (%s) not supported", file);
|
snprintf(error_message, sizeof(error_message),
|
||||||
|
"dlopen (%s) not supported", file);
|
||||||
return NULL;
|
return NULL;
|
||||||
#else
|
#else
|
||||||
void *vp;
|
void *vp;
|
||||||
|
|
||||||
if ((vp = dlopen((char *) file, num)) == (void *) NULL)
|
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;
|
return vp;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -78,7 +80,8 @@ void *
|
|||||||
BSD44_derived_dlsym(void *handle, const char *name)
|
BSD44_derived_dlsym(void *handle, const char *name)
|
||||||
{
|
{
|
||||||
#if defined(__mips__)
|
#if defined(__mips__)
|
||||||
sprintf(error_message, "dlsym (%s) failed", name);
|
snprintf(error_message, sizeof(error_message),
|
||||||
|
"dlsym (%s) failed", name);
|
||||||
return NULL;
|
return NULL;
|
||||||
#else
|
#else
|
||||||
void *vp;
|
void *vp;
|
||||||
@ -88,12 +91,13 @@ BSD44_derived_dlsym(void *handle, const char *name)
|
|||||||
|
|
||||||
if (*name != '_')
|
if (*name != '_')
|
||||||
{
|
{
|
||||||
sprintf(buf, "_%s", name);
|
snprintf(buf, sizeof(buf), "_%s", name);
|
||||||
name = buf;
|
name = buf;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if ((vp = dlsym(handle, (char *) name)) == (void *) NULL)
|
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;
|
return vp;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -63,13 +63,15 @@ void *
|
|||||||
BSD44_derived_dlopen(const char *file, int num)
|
BSD44_derived_dlopen(const char *file, int num)
|
||||||
{
|
{
|
||||||
#if defined(__mips__)
|
#if defined(__mips__)
|
||||||
sprintf(error_message, "dlopen (%s) not supported", file);
|
snprintf(error_message, sizeof(error_message),
|
||||||
|
"dlopen (%s) not supported", file);
|
||||||
return NULL;
|
return NULL;
|
||||||
#else
|
#else
|
||||||
void *vp;
|
void *vp;
|
||||||
|
|
||||||
if ((vp = dlopen((char *) file, num)) == (void *) NULL)
|
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;
|
return vp;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -78,7 +80,8 @@ void *
|
|||||||
BSD44_derived_dlsym(void *handle, const char *name)
|
BSD44_derived_dlsym(void *handle, const char *name)
|
||||||
{
|
{
|
||||||
#if defined(__mips__)
|
#if defined(__mips__)
|
||||||
sprintf(error_message, "dlsym (%s) failed", name);
|
snprintf(error_message, sizeof(error_message),
|
||||||
|
"dlsym (%s) failed", name);
|
||||||
return NULL;
|
return NULL;
|
||||||
#elif defined(__ELF__)
|
#elif defined(__ELF__)
|
||||||
return dlsym(handle, name);
|
return dlsym(handle, name);
|
||||||
@ -88,11 +91,12 @@ BSD44_derived_dlsym(void *handle, const char *name)
|
|||||||
|
|
||||||
if (*name != '_')
|
if (*name != '_')
|
||||||
{
|
{
|
||||||
sprintf(buf, "_%s", name);
|
snprintf(buf, sizeof(buf), "_%s", name);
|
||||||
name = buf;
|
name = buf;
|
||||||
}
|
}
|
||||||
if ((vp = dlsym(handle, (char *) name)) == (void *) NULL)
|
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;
|
return vp;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ next_dlsym(void *handle, char *symbol)
|
|||||||
char symbuf[1024];
|
char symbuf[1024];
|
||||||
unsigned long symref = 0;
|
unsigned long symref = 0;
|
||||||
|
|
||||||
sprintf(symbuf, "_%s", symbol);
|
snprintf(symbuf, sizeof(symbuf), "_%s", symbol);
|
||||||
if (!rld_lookup(errorStream, symbuf, &symref))
|
if (!rld_lookup(errorStream, symbuf, &symref))
|
||||||
TransferError(errorStream);
|
TransferError(errorStream);
|
||||||
CloseError(errorStream);
|
CloseError(errorStream);
|
||||||
|
@ -63,13 +63,15 @@ void *
|
|||||||
BSD44_derived_dlopen(const char *file, int num)
|
BSD44_derived_dlopen(const char *file, int num)
|
||||||
{
|
{
|
||||||
#if defined(__mips__)
|
#if defined(__mips__)
|
||||||
sprintf(error_message, "dlopen (%s) not supported", file);
|
snprintf(error_message, sizeof(error_message),
|
||||||
|
"dlopen (%s) not supported", file);
|
||||||
return NULL;
|
return NULL;
|
||||||
#else
|
#else
|
||||||
void *vp;
|
void *vp;
|
||||||
|
|
||||||
if ((vp = dlopen((char *) file, num)) == (void *) NULL)
|
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;
|
return vp;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -78,7 +80,8 @@ void *
|
|||||||
BSD44_derived_dlsym(void *handle, const char *name)
|
BSD44_derived_dlsym(void *handle, const char *name)
|
||||||
{
|
{
|
||||||
#if defined(__mips__)
|
#if defined(__mips__)
|
||||||
sprintf(error_message, "dlsym (%s) failed", name);
|
snprintf(error_message, sizeof(error_message),
|
||||||
|
"dlsym (%s) failed", name);
|
||||||
return NULL;
|
return NULL;
|
||||||
#elif defined(__ELF__)
|
#elif defined(__ELF__)
|
||||||
return dlsym(handle, name);
|
return dlsym(handle, name);
|
||||||
@ -88,11 +91,12 @@ BSD44_derived_dlsym(void *handle, const char *name)
|
|||||||
|
|
||||||
if (*name != '_')
|
if (*name != '_')
|
||||||
{
|
{
|
||||||
sprintf(buf, "_%s", name);
|
snprintf(buf, sizeof(buf), "_%s", name);
|
||||||
name = buf;
|
name = buf;
|
||||||
}
|
}
|
||||||
if ((vp = dlsym(handle, (char *) name)) == (void *) NULL)
|
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;
|
return vp;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user