summaryrefslogtreecommitdiff
path: root/usr
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2019-01-28 09:59:47 +0200
committerDan McDonald <danmcd@joyent.com>2019-02-04 13:39:11 -0500
commitf642269fe771b10890afea92038f4531cd50cfd9 (patch)
treea0eb59c99d345b94e016226f9b2bcbd3447f80e2 /usr
parent8d44205c2de6047b3104694e998664b7a1c527ab (diff)
downloadillumos-joyent-f642269fe771b10890afea92038f4531cd50cfd9.tar.gz
10313 iconv_modules: NULL pointer errors
Reviewed by: Robert Mustacchi <rm@joyent.com> Reviewed by: Gergő Mihály Doma <domag02@gmail.com> Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr')
-rw-r--r--usr/src/lib/iconv_modules/common/utf8%ibm.c13
-rw-r--r--usr/src/lib/iconv_modules/zh/common/UTF-8%zh_HK.hkscs.c2
-rw-r--r--usr/src/lib/iconv_modules/zh/common/UTF-8%zh_TW-big5.c2
-rw-r--r--usr/src/lib/iconv_modules/zh/common/UTF-8%zh_TW-big5p.c2
-rw-r--r--usr/src/lib/iconv_modules/zh/common/UTF-8%zh_TW-euc.c6
-rw-r--r--usr/src/lib/iconv_modules/zh/common/zh_TW-big5%zh_TW-euc.c6
-rw-r--r--usr/src/lib/iconv_modules/zh/common/zh_TW-euc%UTF-8.c2
-rw-r--r--usr/src/lib/iconv_modules/zh/common/zh_TW-euc%zh_TW-big5.c2
-rw-r--r--usr/src/lib/iconv_modules/zh/common/zh_TW-euc%zh_TW-iso2022-7.c10
-rw-r--r--usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-7%UTF-8.c2
-rw-r--r--usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-7%zh_TW-big5.c2
-rw-r--r--usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-7%zh_TW-euc.c4
-rw-r--r--usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-CN-EXT%zh_TW-big5.c2
-rw-r--r--usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-CN-EXT%zh_TW-euc.c2
-rw-r--r--usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-CN-EXT.c24
15 files changed, 38 insertions, 43 deletions
diff --git a/usr/src/lib/iconv_modules/common/utf8%ibm.c b/usr/src/lib/iconv_modules/common/utf8%ibm.c
index c85e69306d..98bde56f83 100644
--- a/usr/src/lib/iconv_modules/common/utf8%ibm.c
+++ b/usr/src/lib/iconv_modules/common/utf8%ibm.c
@@ -29,7 +29,7 @@
#include <errno.h>
#include <sys/types.h>
-#include "tab_lookup.h" /* table lookup data types */
+#include "tab_lookup.h" /* table lookup data types */
#define MSB 0x80 /* most significant bit */
#define ONEBYTE 0xff /* right most byte */
@@ -261,13 +261,8 @@ unsigned long *ibm_code;
* Return: > 0 - converted with enough space in output buffer
* = 0 - no space in outbuf
*/
-int utf8_to_ibm(unidx, ibm_code, buf, buflen, st)
-int unidx;
-unsigned long ibm_code;
-char *buf;
-size_t buflen;
-_icv_state *st;
-
+int utf8_to_ibm(int unidx, unsigned long ibm_code, char *buf, size_t buflen,
+ _icv_state *st)
{
unsigned long val; /* IBM value */
char c1, c2, ibm_str[3];
@@ -316,7 +311,7 @@ _icv_state *st;
*buf = ibm_str[0] = c1;
*(buf+1) = ibm_str[1] = c2;
- ibm_str[2] = NULL;
+ ibm_str[2] = '\0';
#ifdef DEBUG
fprintf(stderr, "\t->%x %x<-\n", *buf, *(buf+1));
diff --git a/usr/src/lib/iconv_modules/zh/common/UTF-8%zh_HK.hkscs.c b/usr/src/lib/iconv_modules/zh/common/UTF-8%zh_HK.hkscs.c
index 6e24d65a31..b397a2856f 100644
--- a/usr/src/lib/iconv_modules/zh/common/UTF-8%zh_HK.hkscs.c
+++ b/usr/src/lib/iconv_modules/zh/common/UTF-8%zh_HK.hkscs.c
@@ -439,7 +439,7 @@ static int utf8_to_hkscs(int unidx, unsigned long hkscscode, char *buf, size_t b
*buf = hkscs_str[0] = c1;
*(buf+1) = hkscs_str[1] = c2;
- hkscs_str[2] = NULL;
+ hkscs_str[2] = '\0';
}
#ifdef DEBUG
diff --git a/usr/src/lib/iconv_modules/zh/common/UTF-8%zh_TW-big5.c b/usr/src/lib/iconv_modules/zh/common/UTF-8%zh_TW-big5.c
index e7cce94272..ae63dacb2e 100644
--- a/usr/src/lib/iconv_modules/zh/common/UTF-8%zh_TW-big5.c
+++ b/usr/src/lib/iconv_modules/zh/common/UTF-8%zh_TW-big5.c
@@ -458,7 +458,7 @@ static int utf8_to_big5(int unidx, unsigned long big5code, char *buf, size_t buf
*buf = big5_str[0] = c1;
*(buf+1) = big5_str[1] = c2;
- big5_str[2] = NULL;
+ big5_str[2] = '\0';
}
#ifdef DEBUG
diff --git a/usr/src/lib/iconv_modules/zh/common/UTF-8%zh_TW-big5p.c b/usr/src/lib/iconv_modules/zh/common/UTF-8%zh_TW-big5p.c
index e10183c212..254616c294 100644
--- a/usr/src/lib/iconv_modules/zh/common/UTF-8%zh_TW-big5p.c
+++ b/usr/src/lib/iconv_modules/zh/common/UTF-8%zh_TW-big5p.c
@@ -361,7 +361,7 @@ static int utf8_to_big5p(int unidx, unsigned long big5pcode, char *buf, size_t b
*buf = big5p_str[0] = c1;
*(buf+1) = big5p_str[1] = c2;
- big5p_str[2] = NULL;
+ big5p_str[2] = '\0';
}
#ifdef DEBUG
diff --git a/usr/src/lib/iconv_modules/zh/common/UTF-8%zh_TW-euc.c b/usr/src/lib/iconv_modules/zh/common/UTF-8%zh_TW-euc.c
index 085e5a9b89..bac7933fca 100644
--- a/usr/src/lib/iconv_modules/zh/common/UTF-8%zh_TW-euc.c
+++ b/usr/src/lib/iconv_modules/zh/common/UTF-8%zh_TW-euc.c
@@ -397,7 +397,7 @@ _icv_iconv(_iconv_st *st, char **inbuf, size_t *inbytesleft,
static int get_plane_no_by_utf(uint_t unicode,
int *unidx, unsigned long *cnscode)
{
- int ret;
+ int ret;
/* test whether it belongs to private Unicode plane 15 */
if (unicode >= Low_UDA_In_Unicode && unicode <= High_UDA_In_Unicode)
@@ -486,7 +486,7 @@ static int utf8_to_cns(int plane_no, int unidx, unsigned long cnscode,
if ( buflen < 2) goto err;
*buf = cns_str[0] = c1;
*(buf+1) = cns_str[1] = c2;
- cns_str[2] = cns_str[3] = cns_str[4] = NULL;
+ cns_str[2] = cns_str[3] = cns_str[4] = '\0';
ret_size = 2;
break;
case 2:
@@ -509,7 +509,7 @@ static int utf8_to_cns(int plane_no, int unidx, unsigned long cnscode,
*(buf+1) = cns_str[1] = PMASK + plane_no;
*(buf+2) = cns_str[2] = c1;
*(buf+3) = cns_str[3] = c2;
- cns_str[4] = NULL;
+ cns_str[4] = '\0';
ret_size = 4;
break;
}
diff --git a/usr/src/lib/iconv_modules/zh/common/zh_TW-big5%zh_TW-euc.c b/usr/src/lib/iconv_modules/zh/common/zh_TW-big5%zh_TW-euc.c
index 6b2394cbf0..6022084d17 100644
--- a/usr/src/lib/iconv_modules/zh/common/zh_TW-big5%zh_TW-euc.c
+++ b/usr/src/lib/iconv_modules/zh/common/zh_TW-big5%zh_TW-euc.c
@@ -234,7 +234,7 @@ static int big5_2nd_byte(char inbuf)
static int get_plane_no_by_big5(const char c1, const char c2,
int *unidx, unsigned long *cnscode)
{
- int ret;
+ int ret;
unsigned long big5code;
big5code = (unsigned long) ((c1 & ONEBYTE) << 8) + (c2 & ONEBYTE);
@@ -300,7 +300,7 @@ static int big5_to_cns(int plane_no, int unidx, unsigned long cnscode,
if ( buflen < 2 ) goto err;
*buf = cns_str[0] = c1;
*(buf+1) = cns_str[1] = c2;
- cns_str[2] = cns_str[3] = cns_str[4] = NULL;
+ cns_str[2] = cns_str[3] = cns_str[4] = '\0';
ret_size = 2;
break;
case 2:
@@ -323,7 +323,7 @@ static int big5_to_cns(int plane_no, int unidx, unsigned long cnscode,
*(unsigned char*)(buf+1) = cns_str[1] = PMASK + plane_no;
*(unsigned char*) (buf+2) = cns_str[2] = c1;
*(unsigned char*) (buf+3) = cns_str[3] = c2;
- cns_str[4] = NULL;
+ cns_str[4] = '\0';
ret_size = 4;
break;
}
diff --git a/usr/src/lib/iconv_modules/zh/common/zh_TW-euc%UTF-8.c b/usr/src/lib/iconv_modules/zh/common/zh_TW-euc%UTF-8.c
index 57955c70b5..4c9f0ac6be 100644
--- a/usr/src/lib/iconv_modules/zh/common/zh_TW-euc%UTF-8.c
+++ b/usr/src/lib/iconv_modules/zh/common/zh_TW-euc%UTF-8.c
@@ -194,7 +194,7 @@ _icv_iconv(_iconv_st *st, char **inbuf, size_t *inbytesleft,
int uconv_num_internal = 0;
st->keepc[1] = (**inbuf);
- st->keepc[2] = st->keepc[3] = NULL;
+ st->keepc[2] = st->keepc[3] = '\0';
n = cns_to_utf8(1, st, *outbuf,
*outbytesleft, &uconv_num_internal);
if (n > 0) {
diff --git a/usr/src/lib/iconv_modules/zh/common/zh_TW-euc%zh_TW-big5.c b/usr/src/lib/iconv_modules/zh/common/zh_TW-euc%zh_TW-big5.c
index bef3fdaac1..c87c9617fa 100644
--- a/usr/src/lib/iconv_modules/zh/common/zh_TW-euc%zh_TW-big5.c
+++ b/usr/src/lib/iconv_modules/zh/common/zh_TW-euc%zh_TW-big5.c
@@ -153,7 +153,7 @@ _icv_iconv(_iconv_st *st, char **inbuf, size_t *inbytesleft,
} else { /* 2-byte Chinese character - plane #1 */
if (**inbuf & MSB) { /* plane #1 */
st->keepc[1] = (**inbuf);
- st->keepc[2] = st->keepc[3] = NULL;
+ st->keepc[2] = st->keepc[3] = '\0';
n = cns_to_big5(1, st->keepc, *outbuf,
*outbytesleft);
if (n > 0) {
diff --git a/usr/src/lib/iconv_modules/zh/common/zh_TW-euc%zh_TW-iso2022-7.c b/usr/src/lib/iconv_modules/zh/common/zh_TW-euc%zh_TW-iso2022-7.c
index 3b66d25797..889d6cbe11 100644
--- a/usr/src/lib/iconv_modules/zh/common/zh_TW-euc%zh_TW-iso2022-7.c
+++ b/usr/src/lib/iconv_modules/zh/common/zh_TW-euc%zh_TW-iso2022-7.c
@@ -207,7 +207,7 @@ _icv_iconv(_iconv_st *st, char **inbuf, size_t *inbytesleft,
if (**inbuf & MSB) { /* plane #1 */
st->cstate = C4;
st->keepc[1] = (**inbuf);
- st->keepc[2] = st->keepc[3] = NULL;
+ st->keepc[2] = st->keepc[3] = '\0';
plane_no = 1;
continue; /* should not advance *inbuf */
} else { /* input char doesn't belong
@@ -403,10 +403,10 @@ size_t
_cv_enconv(struct _cv_state *st, char **cvinbuf, size_t *cvinbytesleft,
char **cvoutbuf, size_t *cvoutbytesleft)
{
- register char *inbuf;
- register char *outbuf;
- register size_t insize;
- register size_t outsize;
+ char *inbuf;
+ char *outbuf;
+ size_t insize;
+ size_t outsize;
unsigned char uc;
int i;
diff --git a/usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-7%UTF-8.c b/usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-7%UTF-8.c
index 08f31be7f2..12b3713ea2 100644
--- a/usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-7%UTF-8.c
+++ b/usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-7%UTF-8.c
@@ -242,7 +242,7 @@ _icv_iconv(_iconv_st *st, char **inbuf, size_t *inbytesleft,
break;
case C6: /* plane #1: 2nd Chinese character */
st->keepc[1] = (char) (**inbuf | MSB);
- st->keepc[2] = st->keepc[3] = NULL;
+ st->keepc[2] = st->keepc[3] = '\0';
n = iso_to_utf8(1, st->keepc, *outbuf,
*outbytesleft);
if (n > 0) {
diff --git a/usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-7%zh_TW-big5.c b/usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-7%zh_TW-big5.c
index 9113b827a2..a2db1a3379 100644
--- a/usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-7%zh_TW-big5.c
+++ b/usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-7%zh_TW-big5.c
@@ -242,7 +242,7 @@ _icv_iconv(_iconv_st *st, char **inbuf, size_t *inbytesleft,
break;
case C6: /* plane #1: 2nd Chinese character */
st->keepc[1] = (char) (**inbuf | MSB);
- st->keepc[2] = st->keepc[3] = NULL;
+ st->keepc[2] = st->keepc[3] = '\0';
n = iso_to_big5(1, st->keepc, *outbuf, *outbytesleft);
if (n > 0) {
(*outbuf) += n;
diff --git a/usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-7%zh_TW-euc.c b/usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-7%zh_TW-euc.c
index 4fcdb8ee07..a7a45db720 100644
--- a/usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-7%zh_TW-euc.c
+++ b/usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-7%zh_TW-euc.c
@@ -104,7 +104,7 @@ struct _cv_state {
};
extern TWNiconv * aTWNiconv();
-extern void adeTWNiconv(TWNiconv *);
+extern void adeTWNiconv(TWNiconv *);
extern size_t aisotoeuc(TWNiconv *, char **, size_t *, char **, size_t *);
extern void areset(TWNiconv *);
@@ -306,7 +306,7 @@ _icv_iconv(_iconv_st *st, char **inbuf, size_t *inbytesleft,
break;
case C6: /* plane #1: 2nd Chinese character */
st->keepc[1] = (char) (**inbuf | MSB);
- st->keepc[2] = st->keepc[3] = NULL;
+ st->keepc[2] = st->keepc[3] = '\0';
n = iso_to_cns(1, st->keepc, *outbuf, *outbytesleft);
if (n > 0) {
(*outbuf) += n;
diff --git a/usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-CN-EXT%zh_TW-big5.c b/usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-CN-EXT%zh_TW-big5.c
index f0ce18663e..059e014a84 100644
--- a/usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-CN-EXT%zh_TW-big5.c
+++ b/usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-CN-EXT%zh_TW-big5.c
@@ -60,7 +60,7 @@ chinese_to_big5( _iconv_st *st, unsigned char **outbuf, size_t *outbytesleft, in
{
table_t key, *ptr;
- if ( st->SSfunc == NULL && st->SOcharset == 'A') { /* GB2312 */
+ if ( st->SSfunc == NONE && st->SOcharset == 'A') { /* GB2312 */
return gb_to_big5(st, outbuf, outbytesleft);
}
diff --git a/usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-CN-EXT%zh_TW-euc.c b/usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-CN-EXT%zh_TW-euc.c
index b1e8f5b7b1..1b1028c528 100644
--- a/usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-CN-EXT%zh_TW-euc.c
+++ b/usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-CN-EXT%zh_TW-euc.c
@@ -54,7 +54,7 @@ static int
chinese_to_euc( _iconv_st *st, unsigned char **outbuf, size_t *outbytesleft, int plane_no )
{
- if ( st->SSfunc == NULL && st->SOcharset == 'A') { /* GB2312 */
+ if ( st->SSfunc == NONE && st->SOcharset == 'A') { /* GB2312 */
return gb_to_euc(st, outbuf, outbytesleft);
}
diff --git a/usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-CN-EXT.c b/usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-CN-EXT.c
index 9718178472..0273e05775 100644
--- a/usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-CN-EXT.c
+++ b/usr/src/lib/iconv_modules/zh/common/zh_TW-iso2022-CN-EXT.c
@@ -64,9 +64,9 @@ _icv_open()
st->ESCstate = OFF;
st->firstbyte = True;
st->numsav = 0;
- st->SOcharset = NULL; /* no default charset */
- st->SS2charset = NULL; /* no default charset */
- st->SS3charset = NULL; /* no default charset */
+ st->SOcharset = 0; /* no default charset */
+ st->SS2charset = 0; /* no default charset */
+ st->SS3charset = 0; /* no default charset */
st->nonidcount = 0;
st->_errno = 0;
@@ -123,9 +123,9 @@ iso2022_icv_iconv(_iconv_st *st, char **inbuf, size_t *inbytesleft,
st->ESCstate = OFF;
st->firstbyte = True;
st->numsav = 0;
- st->SOcharset = NULL;
- st->SS2charset = NULL;
- st->SS3charset = NULL;
+ st->SOcharset = 0;
+ st->SS2charset = 0;
+ st->SS3charset = 0;
st->nonidcount = 0;
st->_errno = 0;
return ((size_t) 0);
@@ -182,7 +182,7 @@ iso2022_icv_iconv(_iconv_st *st, char **inbuf, size_t *inbytesleft,
} else if ( st->ESCstate != OFF ) { /* Continue processing the
escape sequence */
ret = process_esc_seq( **inbuf, st );
- if ( ret == DONE ) { /* ESC seq interpreted correctly.
+ if ( ret == DONE ) { /* ESC seq interpreted correctly.
Switch off the escape machine */
st->ESCstate = OFF;
} else if ( ret == INVALID ){
@@ -207,13 +207,13 @@ iso2022_icv_iconv(_iconv_st *st, char **inbuf, size_t *inbytesleft,
st->_errno = errno = EILSEQ;
st->nonidcount += 1; /* For this character */
}
- st->numsav = 0; /* Discard the saved characters of
+ st->numsav = 0; /* Discard the saved characters of
invalid sequence */
st->ESCstate = OFF;
} /* more char. needed for escape sequence */
} else if (st->Sfunc == SI) {
/* Switch state to SO only if SOdesignation is set. */
- if ( **inbuf == SO && st->SOcharset != NULL ){
+ if ( **inbuf == SO && st->SOcharset != 0 ){
st->Sfunc = SO;
} else { /* Is ASCII */
n = ascii_to_euc(**inbuf, st, outbuf, outbytesleft );
@@ -268,7 +268,7 @@ process_esc_seq( char c, _iconv_st *st )
case E0:
switch (c){
case SS2LOW:
- if ( st->SS2charset == NULL ){
+ if ( st->SS2charset == 0 ){
/* We do not expect SS2 shift function before
SS2 designation is set */
st->savbuf[0] = ESC;
@@ -281,7 +281,7 @@ process_esc_seq( char c, _iconv_st *st )
st->nonidcount -= 1;
return(DONE);
case SS3LOW:
- if ( st->SS3charset == NULL ){
+ if ( st->SS3charset == 0 ){
/* We do not expect SS3 shift function before
SS3 designation is set */
st->savbuf[0] = ESC;
@@ -384,7 +384,7 @@ iscns( _iconv_st *st )
{
int plane_no = -1;
- if ( st->SSfunc == NULL && st->SOcharset == 'G' )
+ if ( st->SSfunc == NONE && st->SOcharset == 'G' )
plane_no = 1;
else if ( st->SSfunc == SS2 && st->SS2charset == 'H' )
plane_no = 2;