aboutsummaryrefslogtreecommitdiff
path: root/libX11/src/xcms/cmsColNm.c
diff options
context:
space:
mode:
Diffstat (limited to 'libX11/src/xcms/cmsColNm.c')
-rw-r--r--libX11/src/xcms/cmsColNm.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/libX11/src/xcms/cmsColNm.c b/libX11/src/xcms/cmsColNm.c
index a6749c02e..8d0d4a771 100644
--- a/libX11/src/xcms/cmsColNm.c
+++ b/libX11/src/xcms/cmsColNm.c
@@ -40,6 +40,7 @@
#include <sys/stat.h>
#include <stdio.h>
#include <ctype.h>
+#include <limits.h>
#define XK_LATIN1
#include <X11/keysymdef.h>
#include "Cv.h"
@@ -542,7 +543,10 @@ stringSectionSize(
char *pBuf;
char *f1;
char *f2;
- int i;
+ size_t i;
+
+ unsigned int numEntries = 0;
+ unsigned int sectionSize = 0;
*pNumEntries = 0;
*pSectionSize = 0;
@@ -576,26 +580,37 @@ stringSectionSize(
return(XcmsFailure);
}
- (*pNumEntries)++;
+ numEntries++;
+ if (numEntries >= INT_MAX)
+ return(XcmsFailure);
- (*pSectionSize) += (i = strlen(f1)) + 1;
+ i = strlen(f1);
+ if (i >= INT_MAX - sectionSize)
+ return(XcmsFailure);
+ sectionSize += i + 1;
for (; i; i--, f1++) {
/* REMOVE SPACES FROM COUNT */
if (isspace(*f1)) {
- (*pSectionSize)--;
+ sectionSize--;
}
}
- (*pSectionSize) += (i = strlen(f2)) + 1;
+ i = strlen(f2);
+ if (i >= INT_MAX - sectionSize)
+ return(XcmsFailure);
+ sectionSize += i + 1;
for (; i; i--, f2++) {
/* REMOVE SPACES FROM COUNT */
if (isspace(*f2)) {
- (*pSectionSize)--;
+ sectionSize--;
}
}
}
+ *pNumEntries = (int) numEntries;
+ *pSectionSize = (int) sectionSize;
+
return(XcmsSuccess);
}