1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00

dtudcfonted: Resolve further coverity issues

This commit is contained in:
Peter Howkins 2018-03-30 22:09:47 +01:00
parent e507de959e
commit e195df4b50
20 changed files with 51 additions and 44 deletions

View file

@ -137,8 +137,7 @@ String message;
}; };
static NButton BTN = NBUTTONS( buttons ); static NButton BTN = NBUTTONS( buttons );
strcpy( bmsg, resource.mn_cpy_lost ); snprintf(bmsg, sizeof(bmsg), "%s%s", resource.mn_cpy_lost, message);
strcat( bmsg, message );
SetItemLabel(&BTN, 0, resource.l_ok); SetItemLabel(&BTN, 0, resource.l_ok);
SetItemLabel(&BTN, 1, resource.l_cancel); SetItemLabel(&BTN, 1, resource.l_cancel);
PopupNotice( cpyPtnW, bmsg, D_WARNING, &BTN, False, resource.l_warning_title); PopupNotice( cpyPtnW, bmsg, D_WARNING, &BTN, False, resource.l_warning_title);

View file

@ -548,13 +548,13 @@ font_init()
xlf_count = udc_count = sty_count = wls_count = hls_count = 0; xlf_count = udc_count = sty_count = wls_count = hls_count = 0;
if (FalGetFontList(NULL, FAL_FONT_MASK_DEFINED | if (FalGetFontList(NULL, FAL_FONT_MASK_DEFINED |
FAL_FONT_MASK_UNDEFINED, &fontlist) == FAL_ERROR) { FAL_FONT_MASK_UNDEFINED, &fontlist) == FAL_ERROR) {
strcpy(err, FAL_ERROR_STR); snprintf(err, sizeof(err), "%s", FAL_ERROR_STR);
Error_message((Widget)NULL, err); Error_message((Widget)NULL, err);
return; return;
} }
if(fontlist->num == 0) { if(fontlist->num == 0) {
FalFreeFontList(fontlist); FalFreeFontList(fontlist);
strcpy(err, resource.mn_no_font); snprintf(err, sizeof(err), "%s", resource.mn_no_font);
Error_message((Widget)NULL, err); Error_message((Widget)NULL, err);
return; return;
} }
@ -622,15 +622,15 @@ font_init()
(XtCallbackProc)udc_call, NULL); (XtCallbackProc)udc_call, NULL);
for (i=0; i < udc_count; i++) { for (i=0; i < udc_count; i++) {
if(udc[i] == FAL_FONT_CS0) if(udc[i] == FAL_FONT_CS0)
sprintf(tmp, CS0); snprintf(tmp, sizeof(tmp), "%s", CS0);
else if(udc[i] == FAL_FONT_CS1) else if(udc[i] == FAL_FONT_CS1)
sprintf(tmp, CS1); snprintf(tmp, sizeof(tmp), "%s", CS1);
else if(udc[i] == FAL_FONT_CS2) else if(udc[i] == FAL_FONT_CS2)
sprintf(tmp, CS2); snprintf(tmp, sizeof(tmp), "%s", CS2);
else if(udc[i] == FAL_FONT_CS3) else if(udc[i] == FAL_FONT_CS3)
sprintf(tmp, CS3); snprintf(tmp, sizeof(tmp), "%s", CS3);
else else
sprintf(tmp, "Codeset %x?", udc[i]); snprintf(tmp, sizeof(tmp), "Codeset %x?", udc[i]);
button1[i] = XmCreatePushButton(pull1, tmp, NULL, 0); button1[i] = XmCreatePushButton(pull1, tmp, NULL, 0);
XtManageChild(button1[i]); XtManageChild(button1[i]);
XtAddCallback(button1[i], XmNactivateCallback, XtAddCallback(button1[i], XmNactivateCallback,
@ -653,7 +653,7 @@ font_init()
XtAddCallback(button, XmNactivateCallback, XtAddCallback(button, XmNactivateCallback,
(XtCallbackProc)wls_call, NULL); (XtCallbackProc)wls_call, NULL);
for (i=0; i < wls_count; i++) { for (i=0; i < wls_count; i++) {
sprintf(tmp, "%d", wls[i]); snprintf(tmp, sizeof(tmp), "%d", wls[i]);
button3[i] = XmCreatePushButton(pull3, tmp, NULL, 0); button3[i] = XmCreatePushButton(pull3, tmp, NULL, 0);
XtManageChild(button3[i]); XtManageChild(button3[i]);
XtAddCallback(button3[i], XmNactivateCallback, XtAddCallback(button3[i], XmNactivateCallback,
@ -665,7 +665,7 @@ font_init()
XtAddCallback(button, XmNactivateCallback, XtAddCallback(button, XmNactivateCallback,
(XtCallbackProc)hls_call, NULL); (XtCallbackProc)hls_call, NULL);
for (i=0; i < hls_count; i++) { for (i=0; i < hls_count; i++) {
sprintf(tmp, "%d", hls[i]); snprintf(tmp, sizeof(tmp), "%d", hls[i]);
button4[i] = XmCreatePushButton(pull4, tmp, NULL, 0); button4[i] = XmCreatePushButton(pull4, tmp, NULL, 0);
XtManageChild(button4[i]); XtManageChild(button4[i]);
XtAddCallback(button4[i], XmNactivateCallback, XtAddCallback(button4[i], XmNactivateCallback,

View file

@ -1153,8 +1153,8 @@ char *output;
char fbuf[BUFSIZE], split[BUFSIZE] ; char fbuf[BUFSIZE], split[BUFSIZE] ;
char *ep, *pix_sz, *point_sz, *rsl_x, *av_width, *char_set ; char *ep, *pix_sz, *point_sz, *rsl_x, *av_width, *char_set ;
strcpy( fbuf, font ) ; snprintf( fbuf, sizeof(fbuf), "%s", font ) ;
strcpy( split, font ) ; snprintf( split, sizeof(split), "%s", font ) ;
ep = fbuf ; ep = fbuf ;
ep += strlen( fbuf ) ; ep += strlen( fbuf ) ;
ep-- ; ep-- ;

View file

@ -289,7 +289,7 @@ char *argv[];
time(&clock); time(&clock);
tm = localtime(&clock); tm = localtime(&clock);
strcpy( tmbuf, asctime(tm) ) ; snprintf( tmbuf, sizeof(tmbuf), "%s", asctime(tm) ) ;
k = sprintf(bufp,"COMMENT Created date : %s\n",tmbuf ); k = sprintf(bufp,"COMMENT Created date : %s\n",tmbuf );
bufp += k-1; bufp += k-1;

View file

@ -570,7 +570,7 @@ FalGlyphRegion *gr ;
int err_flg = 0; int err_flg = 0;
int code_num; int code_num;
char *tmp; char *tmp;
FalGIInf *gi ; FalGIInf *gi = NULL;
int num_gi ; int num_gi ;
int i, code ; int i, code ;
@ -600,6 +600,9 @@ FalGlyphRegion *gr ;
} }
} }
} }
XFree(gi);
if( !err_flg ) { if( !err_flg ) {
for( i=0; i<num_gr; i++ ) { for( i=0; i<num_gr; i++ ) {
if( (code_num >= gr[i].start) && (code_num <= gr[i].end) ) if( (code_num >= gr[i].start) && (code_num <= gr[i].end) )

View file

@ -42,8 +42,8 @@
#define FONT_FILE_PARM 0 #define FONT_FILE_PARM 0
#define COMM_SNF_POPEN( permission, snf_file, out_file, ep, buf, command ) { \ #define COMM_SNF_POPEN( permission, snf_file, out_file, ep, buf, command ) { \
strcpy( (buf), " -i " ) ; \ snprintf( (buf), sizeof((buf)), " -i " ) ; \
sprintf( (command), "%s %s > %s", bdftosnf, (buf), (out_file) ); \ snprintf( (command), sizeof((command)), "%s %s > %s", bdftosnf, (buf), (out_file) ); \
} }
#define COMM_SNF_FILEVERSION( snf_fd, finf, buf, permission ) { \ #define COMM_SNF_FILEVERSION( snf_fd, finf, buf, permission ) { \
read( (snf_fd), (buf), sizeof(FontInfoRec) ); \ read( (snf_fd), (buf), sizeof(FontInfoRec) ); \
@ -142,7 +142,7 @@
#define COMM_SETSTYLE_TO_FONTDATA( style, key, mask ) { \ #define COMM_SETSTYLE_TO_FONTDATA( style, key, mask ) { \
if( style ) { \ if( style ) { \
char stylebuf[ BUFSIZE ] ; \ char stylebuf[ BUFSIZE ] ; \
strcpy( stylebuf, style ) ; \ snprintf( stylebuf, sizeof(stylebuf), "%s", style ) ; \
key.style.name = stylebuf ; \ key.style.name = stylebuf ; \
mask |= FAL_FONT_MASK_STYLE_NAME ; \ mask |= FAL_FONT_MASK_STYLE_NAME ; \
} \ } \
@ -244,13 +244,13 @@
}\ }\
} \ } \
if ( ( (srch_path) = getenv( DTUDCFONTS ) ) == NULL ) { \ if ( ( (srch_path) = getenv( DTUDCFONTS ) ) == NULL ) { \
sprintf( (list_d), "%s/%s", DTUDCFONTSLISTDIR, (list_file) ); \ snprintf( (list_d), sizeof(list_d), "%s/%s", DTUDCFONTSLISTDIR, (list_file) ); \
sprintf( (list_c), "%s/C/%s", DTUDCFONTSLISTDIR, (list_file) ); \ snprintf( (list_c), sizeof(list_c), "%s/C/%s", DTUDCFONTSLISTDIR, (list_file) ); \
sprintf( (list_l), "%s/%s/%s", DTUDCFONTSLISTDIR, (locale), (list_file) ); \ snprintf( (list_l), sizeof(list_l), "%s/%s/%s", DTUDCFONTSLISTDIR, (locale), (list_file) ); \
} else { \ } else { \
sprintf( (list_d), "%s/%s", (srch_path), (list_file) ); \ snprintf( (list_d), sizeof(list_d), "%s/%s", (srch_path), (list_file) ); \
sprintf( (list_c), "%s/C/%s", (srch_path), (list_file) ); \ snprintf( (list_c), sizeof(list_c), "%s/C/%s", (srch_path), (list_file) ); \
sprintf( (list_l), "%s/%s/%s", (srch_path), (locale), (list_file) ); \ snprintf( (list_l), sizeof(list_l), "%s/%s/%s", (srch_path), (locale), (list_file) ); \
} \ } \
} }

View file

@ -114,7 +114,7 @@ static char *udc_font_sp ;
} }
#define GETXLFDELMSTR( sp, xlfdname, elm_num ) { \ #define GETXLFDELMSTR( sp, xlfdname, elm_num ) { \
strcpy( udc_font_str_buffer, (xlfdname) ) ; \ snprintf( udc_font_str_buffer, sizeof(udc_font_str_buffer), "%s", (xlfdname) ) ; \
udc_font_sp = udc_font_str_buffer ; \ udc_font_sp = udc_font_str_buffer ; \
udc_font_elm_cnt = 0 ;\ udc_font_elm_cnt = 0 ;\
while(*udc_font_sp){\ while(*udc_font_sp){\
@ -137,7 +137,7 @@ static char *udc_font_sp ;
} }
#define GETCHARSETSTR( char_set, xlfdname ) { \ #define GETCHARSETSTR( char_set, xlfdname ) { \
strcpy( udc_font_str_buffer, (xlfdname) ) ; \ snprintf( udc_font_str_buffer, sizeof(udc_font_str_buffer), "%s", (xlfdname) ) ; \
POINTXLFDELM( (char_set), udc_font_str_buffer, XLFD_ELM_CHARSET_REGISTRY ) ; \ POINTXLFDELM( (char_set), udc_font_str_buffer, XLFD_ELM_CHARSET_REGISTRY ) ; \
(char_set)++ ; \ (char_set)++ ; \
} }

View file

@ -413,7 +413,7 @@ _fallcParseCharSet(charset)
if (charset->name) { if (charset->name) {
charset->xrm_name = falrmStringToQuark(charset->name); charset->xrm_name = falrmStringToQuark(charset->name);
strcpy(buf, charset->name); snprintf(buf, sizeof(buf), "%s", charset->name);
if (ptr = strchr(buf, ':')) if (ptr = strchr(buf, ':'))
*ptr = '\0'; *ptr = '\0';
charset->xrm_encoding_name = falrmStringToQuark(buf); charset->xrm_encoding_name = falrmStringToQuark(buf);

View file

@ -478,7 +478,7 @@ static int
append_value_list() append_value_list()
{ {
char **value_list = parse_info.value; char **value_list = parse_info.value;
char *value; char *value = NULL;
int value_num = parse_info.value_num; int value_num = parse_info.value_num;
int value_len = parse_info.value_len; int value_len = parse_info.value_len;
char *str = parse_info.buf; char *str = parse_info.buf;
@ -533,9 +533,9 @@ append_value_list()
if(value_list){ if(value_list){
Xfree((char **)value_list); Xfree((char **)value_list);
} }
if(value){
Xfree(value); Xfree(value);
}
parse_info.value = (char **)NULL; parse_info.value = (char **)NULL;
parse_info.value_num = 0; parse_info.value_num = 0;
parse_info.value_len = 0; parse_info.value_len = 0;

View file

@ -271,6 +271,8 @@ create_conv(methods)
if (conv == NULL) if (conv == NULL)
return (XlcConv) NULL; return (XlcConv) NULL;
conv->state = NULL;
state = (State) Xmalloc(sizeof(StateRec)); state = (State) Xmalloc(sizeof(StateRec));
if (state == NULL) if (state == NULL)
goto err; goto err;

View file

@ -289,10 +289,10 @@ _fallcResolveLocaleName(lc_name, full_name, language, territory, codeset)
} }
if(name != NULL){ if(name != NULL){
strcpy(buf, name); snprintf(buf, sizeof(buf), "%s", name);
Xfree(name); Xfree(name);
}else{ }else{
strcpy(buf, lc_name); snprintf(buf, sizeof(buf), "%s", lc_name);
} }
if(full_name != NULL){ if(full_name != NULL){
strcpy(full_name, buf); strcpy(full_name, buf);

View file

@ -1489,7 +1489,7 @@ mbtocs(conv, from, from_left, to, to_left, args, num_args)
XlcSide side; XlcSide side;
CodeSet codeset = NULL; CodeSet codeset = NULL;
XlcCharSet charset; XlcCharSet charset = NULL;
ParseInfo parse_info; ParseInfo parse_info;
XPointer p; XPointer p;

View file

@ -546,7 +546,7 @@ XLCdGenericPart *gen;
Xfree(charsetd->encoding_name); Xfree(charsetd->encoding_name);
} }
*/ */
tmp = (char *)Xmalloc(strlen(value[0]+1)); tmp = (char *)Xmalloc(strlen(value[0]) + 1);
strcpy(tmp,value[0]); strcpy(tmp,value[0]);
charsetd->encoding_name = tmp; charsetd->encoding_name = tmp;
charsetd->xrm_encoding_name = charsetd->xrm_encoding_name =

View file

@ -726,7 +726,7 @@ parse_omit_name(oc, font_data, pattern)
} }
} }
strcpy(buf, pattern); snprintf(buf, sizeof(buf), "%s", pattern);
length = strlen(pattern); length = strlen(pattern);
last = buf + length - 1; last = buf + length - 1;
if (length > 1 && *last == '*' && *(last - 1) == '-') { if (length > 1 && *last == '*' && *(last - 1) == '-') {

View file

@ -331,6 +331,7 @@ char *charsetname;
if( !_fallcCompareISOLatin1(font_data[i].name,charset_str)){ if( !_fallcCompareISOLatin1(font_data[i].name,charset_str)){
for(k=0;k<font_data[i].scopes_num;k++){ for(k=0;k<font_data[i].scopes_num;k++){
if( gi_to_vgi(gi,vgi,&(font_data[i].scopes[k])) == True){ if( gi_to_vgi(gi,vgi,&(font_data[i].scopes[k])) == True){
XFree(font_data);
return(True); return(True);
} }
} }
@ -341,6 +342,7 @@ char *charsetname;
free_fontdata(font_data); free_fontdata(font_data);
*/ */
*vgi = gi; *vgi = gi;
XFree(font_data);
return(True); return(True);
} }
@ -607,12 +609,14 @@ char *charsetname;
for(k=0;k<font_data[i].scopes_num;k++){ for(k=0;k<font_data[i].scopes_num;k++){
if( vgi_to_gi(glyph,vglyph,&(font_data[i].scopes[k])) == True){ if( vgi_to_gi(glyph,vglyph,&(font_data[i].scopes[k])) == True){
strcpy(charsetname,font_data[i].name); strcpy(charsetname,font_data[i].name);
XFree(font_data);
return(True); return(True);
} }
} }
} }
} }
*glyph = vglyph; *glyph = vglyph;
XFree(font_data);
return(True); return(True);
} }
int int

View file

@ -274,6 +274,7 @@ int lockflag;
fal_utyerror = _FAL_OPEN_ER; fal_utyerror = _FAL_OPEN_ER;
fal_utyderror = errno; fal_utyderror = errno;
fal_utyerrno |= (FAL_FUNCNUM_OPNFNT<<8) ; fal_utyerrno |= (FAL_FUNCNUM_OPNFNT<<8) ;
close( fd );
return (FalFontID)FAL_ERROR; return (FalFontID)FAL_ERROR;
} }
} else { } else {
@ -3086,7 +3087,7 @@ unsigned int *glidx ;
return FAL_ERROR; return FAL_ERROR;
} }
GETCHARSETSTR( char_set, tmp_data.xlfdname ) ; GETCHARSETSTR( char_set, tmp_data.xlfdname ) ;
strcpy( charset_name, char_set ) ; snprintf( charset_name, sizeof(charset_name), "%s", char_set ) ;
} }
/* /*

View file

@ -848,6 +848,7 @@ FalFontData *databuff ;
}else{ }else{
set_errfile_str( fal_err_file, finf->fname ) ; set_errfile_str( fal_err_file, finf->fname ) ;
fal_utyerrno = FAL_ERR_PROP_FNAME ; fal_utyerrno = FAL_ERR_PROP_FNAME ;
free(fnt);
return( _FAL_TRY_NEXT ) ; return( _FAL_TRY_NEXT ) ;
} }

View file

@ -1142,7 +1142,7 @@ char **fontname ;
ep++ ; ep++ ;
} }
*ep = '\0' ; *ep = '\0' ;
strcpy(fntbuf, sp) ; snprintf(fntbuf, sizeof(fntbuf), "%s", sp) ;
getstat |= 0x01 ; getstat |= 0x01 ;
fclose( fp ); fclose( fp );
if (head.snf_file != NULL) { if (head.snf_file != NULL) {

View file

@ -1638,7 +1638,7 @@ char *path;
char *cmd; char *cmd;
#endif #endif
{ {
char *cmd_path; char *cmd_path = NULL;
struct stat st; struct stat st;
char *end; char *end;
char chr_sv; char chr_sv;
@ -1660,7 +1660,7 @@ char *cmd;
if( st.st_mode & S_IFREG ) { if( st.st_mode & S_IFREG ) {
cmd_path = realloc( cmd_path, strlen( cmd_path ) + 1 ); cmd_path = realloc( cmd_path, strlen( cmd_path ) + 1 );
return cmd_path; return cmd_path;
} else continue ; }
} }
FreeString( cmd_path ) ; FreeString( cmd_path ) ;
} }

View file

@ -954,10 +954,7 @@ Widget *footer;
if (strchr(buttons->items[i].label, buttons->items[i].mnemonic)){ if (strchr(buttons->items[i].label, buttons->items[i].mnemonic)){
sprintf(buf, "%s", buttons->items[i].label); sprintf(buf, "%s", buttons->items[i].label);
}else{ }else{
strcpy(buf, buttons->items[i].label); snprintf(buf, sizeof(buf), "%s(%s)", buttons->items[i].label, &(buttons->items[i].mnemonic));
strcat(buf, "(");
strcat(buf, &(buttons->items[i].mnemonic));
strcat(buf, ")");
} }
cs = XmStringCreateLocalized(buf); cs = XmStringCreateLocalized(buf);
XtSetArg(arg[n],XmNmnemonic, buttons->items[i].mnemonic ); n++; XtSetArg(arg[n],XmNmnemonic, buttons->items[i].mnemonic ); n++;