[liblouis-liblouisxml] [liblouis] r806 committed - Checking arguments for NULL to prevent crashes

  • From: liblouis@xxxxxxxxxxxxxx
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Mon, 24 Sep 2012 05:07:27 +0000

Revision: 806
Author:   john.boyer@xxxxxxxxxxxxxxxxx
Date:     Sun Sep 23 22:07:03 2012
Log:      Checking arguments for NULL to prevent crashes
http://code.google.com/p/liblouis/source/detail?r=806

Modified:
 /trunk/liblouis/compileTranslationTable.c
 /trunk/liblouis/lou_backTranslateString.c
 /trunk/liblouis/lou_translateString.c

=======================================
--- /trunk/liblouis/compileTranslationTable.c   Wed Sep 19 22:46:50 2012
+++ /trunk/liblouis/compileTranslationTable.c   Sun Sep 23 22:07:03 2012
@@ -140,11 +140,14 @@
 */

 static char dataPath[MAXSTRING];
-static char *dataPathPtr = NULL;
+static char *dataPathPtr;

 char *EXPORT_CALL
 lou_setDataPath (char *path)
 {
+  dataPathPtr = NULL;
+  if (path == NULL)
+    return NULL;
   strcpy (dataPath, path);
   dataPathPtr = dataPath;
   return dataPathPtr;
@@ -4445,6 +4448,8 @@
 * ASCII8*/
   int ch;
   static FileInfo nested;
+  if (fileName == NULL)
+    return 0;
   if (*mode == 1)
     {
       *mode = 0;
@@ -4604,6 +4609,8 @@
 /* This function can be used to make changes to tables on the fly. */
   int k;
   FileInfo nested;
+  if (inString == NULL)
+    return 0;
   nested.fileName = inString;
   nested.encoding = noEncoding;
   nested.lineNumber = 1;
=======================================
--- /trunk/liblouis/lou_backTranslateString.c   Wed May 30 10:00:22 2012
+++ /trunk/liblouis/lou_backTranslateString.c   Sun Sep 23 22:07:03 2012
@@ -57,17 +57,17 @@
 static int cursorStatus;

 int EXPORT_CALL
-lou_backTranslateString (const char *trantab, const widechar
+lou_backTranslateString (const char *tableList, const widechar
                         * inbuf,
                         int *inlen, widechar * outbuf, int *outlen, char
                         *typeform, char *spacing, int modex)
 {
-  return lou_backTranslate (trantab, inbuf, inlen, outbuf, outlen,
+  return lou_backTranslate (tableList, inbuf, inlen, outbuf, outlen,
                            typeform, spacing, NULL, NULL, NULL, modex);
 }

 int EXPORT_CALL
-lou_backTranslate (const char *trantab, const
+lou_backTranslate (const char *tableList, const
                   widechar
                   * inbuf,
                   int *inlen, widechar * outbuf, int *outlen,
@@ -76,12 +76,15 @@
 {
   int k;
   int goodTrans = 1;
+  if (tableList == NULL || inbuf == NULL || inlen == NULL || outbuf ==
+      NULL || outlen == NULL)
+    return 0;
   if ((modex & otherTrans))
-    return other_backTranslate (trantab, inbuf,
+    return other_backTranslate (tableList, inbuf,
                                inlen, outbuf, outlen,
                                typeform, spacing, outputPos, inputPos,
                                cursorPos, modex);
-  table = lou_getTable (trantab);
+  table = lou_getTable (tableList);
   if (table == NULL)
     return 0;
   srcmax = 0;
=======================================
--- /trunk/liblouis/lou_translateString.c       Tue Sep 18 22:03:06 2012
+++ /trunk/liblouis/lou_translateString.c       Sun Sep 23 22:07:03 2012
@@ -60,6 +60,9 @@
 {
   int k;
   int goodTrans = 1;
+  if (tableList == NULL || inbufx == NULL || inlen == NULL || outbuf ==
+      NULL || outlen == NULL)
+    return 0;
   if ((modex & otherTrans))
     return other_translate (tableList, inbufx,
                            inlen, outbuf, outlen,
@@ -1960,7 +1963,8 @@
   int wordStart;
   int wordEnd;
   table = lou_getTable (tableList);
- if (table == NULL || table->hyphenStatesArray == 0 || inlen >= HYPHSTRING)
+  if (table == NULL || inbuf == NULL || hyphens
+      == NULL || table->hyphenStatesArray == 0 || inlen >= HYPHSTRING)
     return 0;
   if (mode != 0)
     {
@@ -2058,6 +2062,8 @@
 {
   int k;
   widechar dots;
+  if (tableList == NULL || inbuf == NULL || outbuf == NULL)
+    return 0;
   if ((mode & otherTrans))
     return other_dotsToChar (tableList, inbuf, outbuf, length, mode);
   table = lou_getTable (tableList);
@@ -2078,6 +2084,8 @@
                outbuf, int length, int mode)
 {
   int k;
+  if (tableList == NULL || inbuf == NULL || outbuf == NULL)
+    return 0;
   if ((mode & otherTrans))
     return other_charToDots (tableList, inbuf, outbuf, length, mode);

For a description of the software, to download it and links to
project pages go to http://www.abilitiessoft.com

Other related posts:

  • » [liblouis-liblouisxml] [liblouis] r806 committed - Checking arguments for NULL to prevent crashes - liblouis