Skip to content

Commit

Permalink
[StaticScan] Changes due to minor issues found by a static scan
Browse files Browse the repository at this point in the history
Modules changes:

- sr_port/bm_getfree.c - Issues: free_bit (line 216), map_size (line 216), cs1 (line 223),
                         and depth (line 221) are all uninitialized. Additionally,
			 blkhist.cr and blkhist.cycle undefined at line 238.
  - Loop changed so always do one iteration. Will do a new scan and check to see which of
    these issues are fixed by the loop change and which remain.

- sr_port/dse_m_rest.c - Issue: The variable r_top was flagged as uninitialized in line 87.
  - The variable r_top was re-initialized a few lines further down so line 87 was not
    necessary and was removed.
  - Some reformats due to non-standard formatting pre-existing.

- sr_port/dse_shift.c - Issue: lbp undefined in line 99
  - Initialize 'lbp' to NULL earlier so no paths to it are left for it to be undefined.

- sr_port/gtmsource_ctl_init.c - Issue: tmp_ctl resource leak at line 182.
  - Free 'tmp_ctl' when returning or erroring out.

- sr_port/is_canonic_name.c - Issue: Issue was noted via an issue in a different module.
                              In the parse_gv_name_and_subscripts() routine, near the top,
			      seq is set to *subscripts though is never referenced again.
  - Remove variable 'seq' which is not used and may have issues dereferencing 'subscripts'
    when not provided.

- sr_port/mu_int_blk.c - Issue: free_blk_base resource leak going out of scope line 323.
  - Free malloc'd storage (in 'free_blk_base') before return.

- sr_port/mupip_set_journal.c - Issue: Resource leak rewriting gds_info, gds_info not
                                cleaned up.
  - Remove unused gds_info allocation (not plugged into anything) and changed entire clause
    to FILE_CNTL_INIT_IF_NULL() macro to do initialization correctly.

- sr_port/mur_output_show.c - Issue: first_time uninitialized in line 328.
  - Initialize 'first_time' to TRUE so no path to it being uninitialized.

- sr_port/op_fnzsocket.c - Issue: tls_options_mask uninitialized at 598.
  - Move initialization of 'tls_options_mask' up earlier so no paths to uninitialized use.

- sr_port/op_indincr.c - Issue: s is uninitialized at line 101
  - Only do put_tref() if something to put. While this leaves v undefined if there was an
    error, this does not matter because comp_fini() ignores v in that case.

- sr_port/stp_gcol_src.h - Issue: uninitialized value of cstr at line 1063.
  - Make sure cstr is initialized whether expansion succeeds or fails by moving point
    where cstr is set.

- sr_port/tcp_open.c - Issues: 1. resource leak - ai_ptr going out of scope at line 190.
                               2. remote_ai_head uninitialized at line 302.
			       3. calling close (gtm_close) without checking return value at
			          line 355.
			       4. resource leak - remote_ai_head out of scope at line 340.
  - Remove some old Tru64 stuff.
  - Remove unnecessary initialization of remote_ai_ptr.
  - Remove some unused variables.
  - Move hostname validation to client section and remove the conditional parsing of the
    host (required for client) which solves YottaDB#2.
  - Change close() to CLOSEFILE() macros which solves YottaDB#3.
  - Make sure to release linked list at ai_ptr which solves YottaDB#1.
  - Remove assert when erroring with timeout (now tested by online_bkup/online6). This was
    required since the tests in online6 now timeout instead getting GETADDRINFO for invalid
    passive hosts being specified.
  - Make sure release linked list at remote_ai_head (which solves YottaDB#4).

- sr_port/ydberrors.msg
  - Added TCPCONNTIMEOUT message as the other timeout messages didn't quite do what was
    needed. There were a couple util_out_print() timeout message in tcp_open() but it
    really needed to be a real error - especially since it was now being tested in a test
    (online_bkup/online6).

- sr_unix/anticipatory_freeze.c - Issue: Resource leak - handle goes out of scope at line 358.
  - Add an FCLOSE() and error check for same prior to module returns.

- sr_unix/bin_load.c - Issue: Several allocated blocks and buffers need cleanup when leave
  - Implement mechanism to track all of the allocated buffers and free any that are
    allocated if an error occurs or on normal routine return.

- sr_unix/cli_lex.c - Issue: retptr uninitialized at line 488 (return from module).
  - Initialize return value to null so is initialized when nothing is read.

- sr_unix/gtm_getpwuid.c - Originally had changes for an issue but backed those out but left
                           these changes intact anyway.
  - Removed an unneeded return value check from malloc (gtm_malloc does not return if
    no storage).
  - Reformatted an #ifdef block.

- sr_unix/gtmcrypt_entry.c - Issue: Resource leak - handle goes out of scope at line 135.
  - release/close the handle before return

- sr_unix/gtmrecv_end.c - Issue: jnlpool_strm_seqno[idx] uninitialized at line 194.
  - Only do the loop to dump the streams if the journal pool exists.

- sr_unix/gtmsecshr.c - Issue: Resource leak - procstrm goes out of scope at line 1026.
  - Close 'procstrm' before return on error.

- sr_unix/gtmsource_shutdown.c - Issue: maxindex is uninitialized at line 317.
  - Add '!auto_shutdown' to clause as 'maxindex' is only set when !auto_shutdown.

- sr_unix/iosocket_tls.c - Issue: 1. errlen2 is uninitialized at line 416.
                                  2. errlen is unintialized at line 466.
  - Errors aren't using the correct method of getting error out there. The 'errlen'
    var is only seldomly set. Change to use LEN_AND_STR() macro to provide length.

- sr_unix/mu_all_version_standalone.c - Issue: save_errno is unintialized at line 172.
  - Save 'errno' to 'save_errno' to initialize it for the error message.

- sr_unix/mucblkini.c - Issue: Vars bp1, bp2, and bmp were not released before errors.
  - Free these vars appropriately before leaving routine.

- sr_unix/op_zlink.c - Issue: srcnamelen uninitialized line 227.
  - Move initialization of 'srcstr' closer to where used and only for those options
    where srcnamelen is set.

- sr_unix/relinkctl.c - Issue: shm_hdr uninitialized in line 1069
  - Initialize 'shm_hdr' to prevent usage when is still uninitialized.
  - Add error checks and messages for SHMDT invocations.

- sr_unix/ss_anal_shdw_file.c - Issue: bitmap_buffer and bp allocations not freed prior
                                to error returns (lines 118 and 123).
  - Add frees for bitmap_buffer and bp before error returns.

- sr_unix/trigger_source_read_andor_verify.c - Issue: rttabent uninitialized on line 356.
  - Initialize 'rttabent' to NULL
  - If not initialized, set 'rttabent' to our rtn_names list to begin search.

- sr_unix/util_output.c - Issue: Origin of this change is lost. It was from an issue
                          raised for another module and digging down through the calls,
			  we ended up here where a var as uninitialized after this loop
			  because of the lack of a default clause such that 'length'
			  didn't get set IIRC (the chose switch value in the scan's
			  simulation did not match a case).
  - Add default clause to switch with an assert in it. Also added code to keep static
    scan from complaining about 'length'.

- sr_unix/wait_for_disk_space.c - Issue: freeze_cleared uninitialized at line 161
  - Add a default for 'freeze_cleared' so is initialized.

- sr_unix_cm/gtcm_bgn_net.c - Issue: Resource leak - ai_ptr goes out of scope at 135, 148.
  - Release 'ai_ptr' linked list before normal and returns.

- sr_unix_cm/omi_prc_conn.c - Issue: Neither agname or ag_pass allocated memory is
                              released before normal or error return.
  - Define OMI_FREE() macro for better cleanup. Add to any place before error or normal
    return.
  - Initialize 'agname' and 'ag_pass' so know if they are allocated.
  - Remove clauses that test memory allocation result. Note gtm_malloc() does not return
    if allocation fails.

- sr_unix_cm/rc_srvc_xct.c - Issue: Resource leak - elst var goes out of scope at line 198.
  - Added a macro to do the cleanups and added it before all return points.

- sr_unix_gnp/cmi_init.c - Issue: Resource leak - local_ai_ptr out of scope lines
  			   67, 74, 85, 95,122.
  - Some minor formatting changes for code standards.
  - Make sure local_ai_ptr linked list is freed before leave routine.

- sr_unix_gnp/cmi_open.c - Issue: Resource leak - ai_head out of scope line 123.
  - Some minor formatting changes for code standards.
  - Make sure ai_head linked list is freed before leave routine.

- sr_unix_gnp/cmj_get_port.c - Issue: Resource leak - ai_ptr out of scope line 123.
  - Removed - no users of this routine were found.

- sr_unix_gnp/cmj_getsockaddr.c - Issue: Resource leak - ai_ptr out of scope line 152.
  - Make sure ai_ptr linked list is freed before leave routine with this error return.

- sr_unix_gnp/cmu_getclb.c - Issue: Resource leak - ai_ptr out of scope lines 52, 57.
  - Minor changes for coding standards.
  - Make sure ai_ptr linked list is freed before leave routine.

- sr_unix_gnp/gtcm_gnp_server_main.c - Issue: status uninitialized line 287.
  - Change static routines to STATICFN{DCL,DEF} (coding standards)
  - The 'status' variable was not set until after it was referenced. Removed the test
    of the uninitialized status after the fetch.

- sr_unix_gnp/gtcm_open_cmerrlog.c - Issue: Potential to overrun end of lfn_path at
  				     line 80.
  - Change max usable length before truncation to make room for a null terminator.
  • Loading branch information
nars1 authored and estess committed Aug 14, 2018
1 parent def76d8 commit 5e9491b
Show file tree
Hide file tree
Showing 19 changed files with 132 additions and 134 deletions.
3 changes: 2 additions & 1 deletion sr_port/anticipatory_freeze.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ error_def(ERR_TEXT);
{ \
jnlpool->jnlpool_ctl->freeze = 0; \
FREEZE_CLEARED = TRUE; \
} \
} else \
FREEZE_CLEARED = FALSE; \
}

#define REPORT_INSTANCE_UNFROZEN(FREEZE_CLEARED) \
Expand Down
7 changes: 4 additions & 3 deletions sr_port/bm_getfree.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ block_id bm_getfree(block_id hint, boolean_t *blk_used, unsigned int cw_work, cw
sm_uc_ptr_t bmp;
block_id bml, hint_cycled, hint_limit;
block_id_ptr_t b_ptr;
int cw_set_top, depth = 0, lcnt;
int cw_set_top, depth, lcnt;
unsigned int local_maps, map_size, n_decrements = 0, total_blks;
trans_num ctn;
int4 free_bit, offset;
Expand All @@ -94,7 +94,8 @@ block_id bm_getfree(block_id hint, boolean_t *blk_used, unsigned int cw_work, cw
hint_cycled = DIVIDE_ROUND_UP(total_blks, BLKS_PER_LMAP);
hint_limit = DIVIDE_ROUND_DOWN(hint, BLKS_PER_LMAP);
local_maps = hint_cycled + 2; /* for (up to) 2 wraps */
for (lcnt = local_maps + 1; lcnt ; lcnt--) /* loop control counts down for slight efficiency */
lcnt = local_maps + 1;
do
{
bml = bmm_find_free(hint / BLKS_PER_LMAP, (sm_uc_ptr_t)MM_ADDR(cs_data), local_maps);
if ((NO_FREE_SPACE == bml) || (bml >= hint_cycled))
Expand Down Expand Up @@ -211,7 +212,7 @@ block_id bm_getfree(block_id hint, boolean_t *blk_used, unsigned int cw_work, cw
send_msg_csa(CSA_ARG(cs_addrs) VARLSTCNT(3) ERR_DBMBMINCFREFIXED, 1, bml);
bit_clear(bml / BLKS_PER_LMAP, MM_ADDR(cs_data)); /* repair master map error */
}
}
} while (0 < --lcnt);
/* If not in the final retry, it is possible that free_bit is >= map_size, e.g., if the buffer holding the bitmap block
* gets recycled with a non-bitmap block in which case the bit that bm_find_blk returns could be greater than map_size.
* But, this should never happen in final retry.
Expand Down
2 changes: 1 addition & 1 deletion sr_port/dse_shift.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ void dse_shift(void)
uchar_ptr_t lbp;
uint4 offset, shift;

lbp = NULL; /* Initialize */
if (gv_cur_region->read_only)
rts_error_csa(CSA_ARG(cs_addrs) VARLSTCNT(4) ERR_DBRDONLY, 2, DB_LEN_STR(gv_cur_region));
CHECK_AND_RESET_UPDATE_ARRAY; /* reset update_array_ptr to update_array */
Expand All @@ -79,6 +78,7 @@ void dse_shift(void)
if (!cli_get_hex("OFFSET", &offset))
return;
shift = 0;
lbp = NULL;
if (CLI_PRESENT == cli_present("FORWARD"))
{
if (!cli_get_hex("FORWARD", &shift))
Expand Down
75 changes: 29 additions & 46 deletions sr_port/restrict.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,45 +66,32 @@ STATICFNDCL void append_filter(char *, FILE *, char *, char *, int *, char *);
error_def(ERR_RESTRICTSYNTAX);
error_def(ERR_TEXT);

#define PUT_FLNAME_IN_MAPPING_FILE(RPATH, FPATH, FP, C_CALL_NAME, M_REF_NAME, STAT_RM, \
CREATED_NOW, CREATED_NOW_INITIALIZED, SAVE_ERRNO, ERR_STR) \
{ \
if (CREATED_NOW_INITIALIZED) \
{ \
/* Note: "CREATED_NOW" is initialized/usable only if "CREATED_NOW_INITIALIZED" is TRUE */ \
if (CREATED_NOW) \
{ /* We created this file in a prior invocation of PUT_FLNAME_IN_MAPPING_FILE \
* so append all future macro invocations into the same file. \
*/ \
append_filter(FPATH, FP, C_CALL_NAME, M_REF_NAME, SAVE_ERRNO, ERR_STR); \
} \
/* else : We have already determined restrict.txt and filter_commands.tab are in sync time wise. \
* No need to do any more file modification checks. \
*/ \
} else if (ACCESS(FPATH, F_OK)) \
{ /* File does not exist, create and write mapping */ \
CREATED_NOW = TRUE; \
CREATED_NOW_INITIALIZED = TRUE; \
append_filter(FPATH, FP, C_CALL_NAME, M_REF_NAME, SAVE_ERRNO, ERR_STR); \
} else \
{ /* Filter file exists. Check modified time */ \
Stat(RPATH, &rTime); \
rmtime = rTime.st_mtim; \
Stat(FPATH, &fTime); \
fmtime = fTime.st_mtim; \
/* Check if restrict.txt file modification time (rmtime) is newer than \
* filter_commands.tab file modification time (fmtime). If so, recreate filter_commands.tab. \
*/ \
if ((rmtime.tv_sec > fmtime.tv_sec) \
|| ((rmtime.tv_sec == fmtime.tv_sec) && (rmtime.tv_nsec >= fmtime.tv_nsec))) \
{ /* Delete the older mapping file and recreate new if required */ \
CREATED_NOW = TRUE; \
gtm_file_remove(FPATH, strlen(FPATH), &STAT_RM); \
append_filter(FPATH, FP, C_CALL_NAME, M_REF_NAME, SAVE_ERRNO, ERR_STR); \
} else \
CREATED_NOW = FALSE; \
CREATED_NOW_INITIALIZED = TRUE; \
} \
#define PUT_FLNAME_IN_MAPPING_FILE(RPATH, FPATH, FP, C_CALL_NAME, M_REF_NAME, STAT_RM, SAVE_ERRNO, ERR_STR) \
{ \
if (!ACCESS(FPATH, F_OK)) /* Filter file exists, now check modified time */ \
{ \
Stat(RPATH, &rTime); \
rmtime = rTime.st_mtim; \
Stat(FPATH, &fTime); \
fmtime = fTime.st_mtim; \
/* Check if restrict.txt file modification time (rmtime) is newer than \
* filter_commands.tab file modification time (fmtime). If so, recreate filter_commands.tab. \
*/ \
if ((rmtime.tv_sec > fmtime.tv_sec) \
|| ((rmtime.tv_sec == fmtime.tv_sec) && (rmtime.tv_nsec >= fmtime.tv_nsec))) \
{ /* Delete the older mapping file and recreate new if required */ \
created_now = TRUE; \
gtm_file_remove(FPATH, strlen(FPATH), &STAT_RM); \
append_filter(FPATH, FP, C_CALL_NAME, M_REF_NAME, SAVE_ERRNO, ERR_STR); \
} else if (created_now) /* This process created a new file,append to it */ \
{ \
append_filter(FPATH, FP, C_CALL_NAME, M_REF_NAME, SAVE_ERRNO, ERR_STR); \
} \
} else /* File does not exist, create and write mapping */ \
{ \
created_now = TRUE; \
append_filter(FPATH, FP, C_CALL_NAME, M_REF_NAME, SAVE_ERRNO, ERR_STR); \
} \
}

void append_filter(char * fpath, FILE * fp, char * c_call_name, char * m_ref_name, int * save_errno, char * errstr)
Expand Down Expand Up @@ -137,7 +124,7 @@ void restrict_init(void)
struct group grp, *grpres;
char *grpbuf = NULL;
size_t grpbufsz;
boolean_t created_now, created_now_initialized = FALSE;
boolean_t created_now = FALSE;
struct stat rTime, fTime;
struct timespec rmtime, fmtime;

Expand Down Expand Up @@ -187,18 +174,14 @@ void restrict_init(void)
{
restrictions.zsy_filter = TRUE;
PUT_FLNAME_IN_MAPPING_FILE(rfpath, rcfpath, rcfp,
ZSY_C_CALL_NAME, group_or_flname, statrm,
created_now, created_now_initialized,
&save_errno, errstr);
ZSY_C_CALL_NAME, group_or_flname, statrm, &save_errno, errstr);
continue;
}
if (0 == STRNCASECMP(facility, PIPE_FILTER, SIZEOF(PIPE_FILTER)))
{
restrictions.pipe_filter = TRUE;
PUT_FLNAME_IN_MAPPING_FILE(rfpath, rcfpath, rcfp,
PIPE_C_CALL_NAME, group_or_flname, statrm,
created_now, created_now_initialized,
&save_errno, errstr);
PIPE_C_CALL_NAME, group_or_flname, statrm, &save_errno, errstr);
continue;
}
status = getgrnam_r(group_or_flname, &grp, grpbuf, grpbufsz, &grpres);
Expand Down
6 changes: 2 additions & 4 deletions sr_port/tcp_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
* port - numeric port number
* timeout - numeric seconds
* passive - boolean 0 is sender and must have a host, 1 may
* have a host and if so, it is checked to see that
* incomming connections are from that host.
* have a host and if so, it is ignored.
* return:
* socket descriptor for the connection or
* -1 and output the error.
Expand Down Expand Up @@ -335,8 +334,7 @@ int tcp_open(char *host, unsigned short port, int4 timeout, boolean_t passive) /
{
freeaddrinfo(remote_ai_head);
CLOSEFILE(sock, rc);
util_out_print("Connection timed out.", TRUE);
assert(FALSE);
gtm_putmsg_csa(CSA_ARG(NULL) VARLSTCNT(3) ERR_TCPCONNTIMEOUT, 1, timeout);
return -1;
}
freeaddrinfo(remote_ai_head);
Expand Down
52 changes: 29 additions & 23 deletions sr_unix/bin_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ error_def(ERR_DBPRIVERR);
#define BIN_PUT_GVSPAN 4
#define TEXT1 "Record discarded because"

# define FREE_MALLOCS \
{ \
int i; \
for (i = 0; i < ARRAYSIZE(malloc_fields); i++) \
{ \
if (NULL != *(malloc_fields[i])) \
free(*(malloc_fields[i])); \
} \
}

# define GC_BIN_LOAD_ERR(GTMCRYPT_ERRNO) \
{ \
io_log_name *io_log; \
Expand All @@ -117,11 +127,7 @@ error_def(ERR_DBPRIVERR);
io_log = io_curr_device.in->name; \
GTMCRYPT_REPORT_ERROR(GTMCRYPT_ERRNO, gtm_putmsg, io_log->len, io_log->dollar_io); \
mupip_error_occurred = TRUE; \
for (i = 0; i < (sizeof(malloc_fields) / sizeof(char **)); i++) \
{ \
if (NULL != *(malloc_fields[i])) \
free(*(malloc_fields[i])); \
} \
FREE_MALLOCS; \
if (NULL != encr_key_handles) \
{ \
free(encr_key_handles); \
Expand Down Expand Up @@ -264,16 +270,13 @@ void bin_load(uint4 begin, uint4 end, char *line1_ptr, int line1_len)
mstr mstr_src, mstr_dest, opstr;
collseq *extr_collseq, *db_collseq, *save_gv_target_collseq;
coll_hdr extr_collhdr, db_collhdr;
gv_key *tmp_gvkey = NULL; /* null-initialize at start, will be malloced later */
gv_key *sn_gvkey = NULL; /* null-initialize at start, will be malloced later */
gv_key *sn_savekey = NULL; /* null-initialize at start, will be malloced later */
gv_key *save_orig_key = NULL; /* null-initialize at start, will be malloced later */
gv_key *tmp_gvkey, *sn_gvkey, *sn_savekey, *save_orig_key;
gv_key *orig_gv_currkey_ptr = NULL;
char std_null_coll[BIN_HEADER_NUMSZ + 1], *sn_hold_buff, *sn_hold_buff_temp;
int in_len, gtmcrypt_errno, n_index, encrypted_hash_array_len, null_iv_array_len;
char *inbuf, *encrypted_hash_array_ptr, *curr_hash_ptr, *null_iv_array_ptr, null_iv_char;
int4 index;
gtmcrypt_key_t *encr_key_handles = NULL;
gtmcrypt_key_t *encr_key_handles;
boolean_t encrypted_version, mixed_encryption, valid_gblname;
char index_err_buf[1024];
gvnh_reg_t *gvnh_reg;
Expand All @@ -300,13 +303,12 @@ void bin_load(uint4 begin, uint4 end, char *line1_ptr, int line1_len)
(char **)&encrypted_hash_array_ptr,
(char **)&encr_key_handles,
(char **)&null_iv_array_ptr,
&sn_hold_buff,
&sn_hold_buff_temp
&sn_hold_buff
};
DCL_THREADGBL_ACCESS;

SETUP_THREADGBL_ACCESS;
for (i = 0; i < (sizeof(malloc_fields) / sizeof(char *)); i++)
for (i = 0; i < ARRAYSIZE(malloc_fields); i++)
*(malloc_fields[i]) = NULL; /* Make sure all pointers are cleared to start */
assert(4 == SIZEOF(coll_hdr));
gvinit();
Expand All @@ -323,6 +325,7 @@ void bin_load(uint4 begin, uint4 end, char *line1_ptr, int line1_len)
len = file_input_bin_get((char **)&ptr, &file_offset_base, (char **)&ptr_base, DO_RTS_ERROR_FALSE);
if (0 >= len)
{
FREE_MALLOCS;
rts_error_csa(CSA_ARG(NULL) VARLSTCNT(1) ERR_LDBINFMT);
mupip_exit(ERR_LDBINFMT);
}
Expand All @@ -331,6 +334,7 @@ void bin_load(uint4 begin, uint4 end, char *line1_ptr, int line1_len)
((('6' <= hdr_lvl) && ('9' >= hdr_lvl)) && (BIN_HEADER_SZ == len)) ||
(('4' > hdr_lvl) && (V3_BIN_HEADER_SZ == len))))
{
FREE_MALLOCS;
rts_error_csa(CSA_ARG(NULL) VARLSTCNT(1) ERR_LDBINFMT);
mupip_exit(ERR_LDBINFMT);
}
Expand All @@ -339,13 +343,15 @@ void bin_load(uint4 begin, uint4 end, char *line1_ptr, int line1_len)
if (0 != memcmp(ptr, BIN_HEADER_LABEL, SIZEOF(BIN_HEADER_LABEL) - 2) || ('2' > hdr_lvl) ||
*(BIN_HEADER_VERSION_ENCR_IV) < hdr_lvl)
{ /* ignore the level check */
FREE_MALLOCS;
rts_error_csa(CSA_ARG(NULL) VARLSTCNT(1) ERR_LDBINFMT);
mupip_exit(ERR_LDBINFMT);
}
/* check if extract was generated in UTF-8 mode */
utf8_extract = (0 == MEMCMP_LIT(&ptr[len - BIN_HEADER_LABELSZ], UTF8_NAME)) ? TRUE : FALSE;
if ((utf8_extract && !gtm_utf8_mode) || (!utf8_extract && gtm_utf8_mode))
{ /* extract CHSET doesn't match $ZCHSET */
FREE_MALLOCS;
if (utf8_extract)
rts_error_csa(CSA_ARG(NULL) VARLSTCNT(4) ERR_LOADINVCHSET, 2, LEN_AND_LIT("UTF-8"));
else
Expand Down Expand Up @@ -378,6 +384,7 @@ void bin_load(uint4 begin, uint4 end, char *line1_ptr, int line1_len)
extr_std_null_coll = STRTOUL(std_null_coll, NULL, 10);
if (0 != extr_std_null_coll && 1!= extr_std_null_coll)
{
FREE_MALLOCS;
rts_error_csa(CSA_ARG(NULL) VARLSTCNT(5) ERR_TEXT, 2,
RTS_ERROR_TEXT("Corrupted null collation field in header"), ERR_LDBINFMT);
mupip_exit(ERR_LDBINFMT);
Expand Down Expand Up @@ -423,6 +430,7 @@ void bin_load(uint4 begin, uint4 end, char *line1_ptr, int line1_len)
len = file_input_bin_get((char **)&ptr, &file_offset_base, (char **)&ptr_base, DO_RTS_ERROR_TRUE);
if (SIZEOF(coll_hdr) != len)
{
FREE_MALLOCS;
rts_error_csa(CSA_ARG(NULL) VARLSTCNT(5) ERR_TEXT, 2, RTS_ERROR_TEXT("Corrupt collation header"),
ERR_LDBINFMT);
mupip_exit(ERR_LDBINFMT);
Expand All @@ -437,6 +445,7 @@ void bin_load(uint4 begin, uint4 end, char *line1_ptr, int line1_len)
{
if (!(len = file_input_bin_get((char **)&ptr, &file_offset_base, (char **)&ptr_base, DO_RTS_ERROR_TRUE)))
{
FREE_MALLOCS;
gtm_putmsg_csa(CSA_ARG(NULL) VARLSTCNT(3) ERR_LOADEOF, 1, begin);
util_out_print("Error reading record number: !@UQ\n", TRUE, &iter);
mupip_error_occurred = TRUE;
Expand Down Expand Up @@ -520,6 +529,7 @@ void bin_load(uint4 begin, uint4 end, char *line1_ptr, int line1_len)
gtm_putmsg_csa(CSA_ARG(NULL) VARLSTCNT(8) MAKE_MSG_SEVERE(ERR_RECLOAD),
2, LEN_AND_STR(msg_buff), msg_buff, ERR_TEXT, 2,
RTS_ERROR_TEXT(index_err_buf));
FREE_MALLOCS;
return;
}
# ifdef DEBUG
Expand Down Expand Up @@ -643,13 +653,15 @@ void bin_load(uint4 begin, uint4 end, char *line1_ptr, int line1_len)
{
if (!do_verify(extr_collseq, extr_collhdr.act, extr_collhdr.ver))
{
FREE_MALLOCS;
gtm_putmsg_csa(CSA_ARG(cs_addrs) VARLSTCNT(8) ERR_COLLTYPVERSION, 2,
extr_collhdr.act, extr_collhdr.ver, ERR_GVIS, 2,
gv_altkey->end - 1, gv_altkey->base);
mupip_exit(ERR_COLLTYPVERSION);
}
} else
{
FREE_MALLOCS;
gtm_putmsg_csa(CSA_ARG(cs_addrs) VARLSTCNT(7) ERR_COLLATIONUNDEF, 1,
extr_collhdr.act, ERR_GVIS, 2, gv_altkey->end - 1, gv_altkey->base);
mupip_exit(ERR_COLLATIONUNDEF);
Expand All @@ -661,13 +673,15 @@ void bin_load(uint4 begin, uint4 end, char *line1_ptr, int line1_len)
{
if (!do_verify(db_collseq, db_collhdr.act, db_collhdr.ver))
{
FREE_MALLOCS;
gtm_putmsg_csa(CSA_ARG(cs_addrs) VARLSTCNT(8) ERR_COLLTYPVERSION, 2,
db_collhdr.act, db_collhdr.ver, ERR_GVIS, 2,
gv_altkey->end - 1, gv_altkey->base);
mupip_exit(ERR_COLLTYPVERSION);
}
} else
{
FREE_MALLOCS;
gtm_putmsg_csa(CSA_ARG(cs_addrs) VARLSTCNT(7) ERR_COLLATIONUNDEF, 1, db_collhdr.act,
ERR_GVIS, 2, gv_altkey->end - 1, gv_altkey->base);
mupip_exit(ERR_COLLATIONUNDEF);
Expand Down Expand Up @@ -829,8 +843,7 @@ void bin_load(uint4 begin, uint4 end, char *line1_ptr, int line1_len)
break;
}
}
}
else /* It is a negative subscript */
} else /* It is a negative subscript */
{
while ((mych = *subs++) && (STR_SUB_PREFIX != mych)) /* WARNING: assignment */
{
Expand Down Expand Up @@ -1154,14 +1167,7 @@ void bin_load(uint4 begin, uint4 end, char *line1_ptr, int line1_len)
}
assert(NULL != encr_key_handles);
}
for (i = 0; i < (sizeof(malloc_fields) / sizeof(char **)); i++)
{
if (NULL != *(malloc_fields[i]))
{
free(*(malloc_fields[i]));
*(malloc_fields[i]) = NULL;
}
}
FREE_MALLOCS;
file_input_close();
tmp_rec_count = (rec_count == begin) ? rec_count : rec_count - 1;
if (0 != first_failed_rec_count)
Expand Down
Loading

0 comments on commit 5e9491b

Please sign in to comment.