summaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2008-02-08 15:33:26 -0800
committerChris Robinson <[email protected]>2008-02-08 15:33:26 -0800
commit3dd3cd4ceb4666e3e1030c45e0ccd94f810a797b (patch)
tree0a031266ab04844dfc718b104f6ead6688e56a28 /Alc
parent80fcbc8adc17364522af3858e153771948ec8962 (diff)
Prevent overflow of the device lists
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 714a142f..c8060f49 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -262,25 +262,40 @@ static void InitAL(void)
ALCchar *AppendDeviceList(char *name)
{
- static int pos;
+ static size_t pos;
ALCchar *ret = alcDeviceList+pos;
- pos += snprintf(alcDeviceList+pos, sizeof(alcDeviceList)-pos, "%s", name) + 1;
+ if(pos >= sizeof(alcDeviceList))
+ {
+ AL_PRINT("Not enough room to add %s!\n", name);
+ return alcDeviceList + sizeof(alcDeviceList) - 1;
+ }
+ pos += snprintf(alcDeviceList+pos, sizeof(alcDeviceList)-pos-1, "%s", name) + 1;
return ret;
}
ALCchar *AppendAllDeviceList(char *name)
{
- static int pos;
+ static size_t pos;
ALCchar *ret = alcAllDeviceList+pos;
- pos += snprintf(alcAllDeviceList+pos, sizeof(alcAllDeviceList)-pos, "%s", name) + 1;
+ if(pos >= sizeof(alcAllDeviceList))
+ {
+ AL_PRINT("Not enough room to add %s!\n", name);
+ return alcAllDeviceList + sizeof(alcAllDeviceList) - 1;
+ }
+ pos += snprintf(alcAllDeviceList+pos, sizeof(alcAllDeviceList)-pos-1, "%s", name) + 1;
return ret;
}
ALCchar *AppendCaptureDeviceList(char *name)
{
- static int pos;
+ static size_t pos;
ALCchar *ret = alcCaptureDeviceList+pos;
- pos += snprintf(alcCaptureDeviceList+pos, sizeof(alcCaptureDeviceList)-pos, "%s", name) + 1;
+ if(pos >= sizeof(alcCaptureDeviceList))
+ {
+ AL_PRINT("Not enough room to add %s!\n", name);
+ return alcCaptureDeviceList + sizeof(alcCaptureDeviceList) - 1;
+ }
+ pos += snprintf(alcCaptureDeviceList+pos, sizeof(alcCaptureDeviceList)-pos-1, "%s", name) + 1;
return ret;
}