Commit 2639be97d6f2ddd6dfa29e51c8fee72539a3ea54
Committed by
GitHub
Exists in
master
and in
1 other branch
Merge pull request #35 from PerryWerneck/develop
Fixing codeql warnings.
Showing
8 changed files
with
57 additions
and
42 deletions
Show diff stats
Makefile.in
... | ... | @@ -95,7 +95,7 @@ BUILDDIR=@BUILDDIR@ |
95 | 95 | |
96 | 96 | POTDIR=$(BUILDDIR)/.pot |
97 | 97 | |
98 | -OBJDIR=$(BUILDDIR)/.obj | |
98 | +OBJDIR=$(BUILDDIR)/.obj/@OSNAME@ | |
99 | 99 | OBJDBG=$(OBJDIR)/Debug |
100 | 100 | OBJRLS=$(OBJDIR)/Release |
101 | 101 | |
... | ... | @@ -525,7 +525,9 @@ clean: \ |
525 | 525 | cleanDebug \ |
526 | 526 | cleanRelease |
527 | 527 | |
528 | - @rm -fr $(BUILDDIR)/.tmp/$(LIBNAME) | |
528 | + @rm -fr $(BUILDDIR)/.obj | |
529 | + @rm -fr $(BUILDDIR)/.bin | |
530 | + @rm -fr $(BUILDDIR)/.tmp | |
529 | 531 | @rm -fr $(POTDIR)/$(LIBNAME) |
530 | 532 | @rm -f locale/*.pot |
531 | 533 | ... | ... |
src/core/ansi.c
... | ... | @@ -1729,7 +1729,7 @@ ansi_send_pf(H3270 *hSession, int nn) { |
1729 | 1729 | |
1730 | 1730 | if (nn < 1 || ((size_t) nn) > sizeof(code)/sizeof(code[0])) |
1731 | 1731 | return; |
1732 | - (void) sprintf(fn_buf, ", "\033[%d~", code[nn-1]);33[%d~", code[nn-1]); | |
1732 | + (void) snprintf(fn_buf, sizeof(fn_buf), ", "\033[%d~", code[nn-1]);33[%d~", code[nn-1]); | |
1733 | 1733 | net_sends(hSession,fn_buf); |
1734 | 1734 | } |
1735 | 1735 | ... | ... |
src/core/cursor.c
... | ... | @@ -90,7 +90,8 @@ LIB3270_EXPORT int lib3270_move_cursor(H3270 *hSession, LIB3270_DIRECTION dir, u |
90 | 90 | status_reset(hSession); |
91 | 91 | } else { |
92 | 92 | struct ta *ta = new_ta(hSession, TA_TYPE_CURSOR_MOVE); |
93 | - | |
93 | + if(!ta) | |
94 | + return -1; | |
94 | 95 | ta->args.move.direction = dir; |
95 | 96 | ta->args.move.fn = lib3270_move_cursor; |
96 | 97 | ta->args.move.sel = sel; | ... | ... |
src/core/ft/ft.c
... | ... | @@ -474,7 +474,7 @@ LIB3270_EXPORT int lib3270_ft_start(H3270 *hSession) { |
474 | 474 | // Erase the line and enter the command. |
475 | 475 | flen = kybd_prime(ft->host); |
476 | 476 | if (!flen || flen < strlen(buffer) - 1) { |
477 | - lib3270_write_log(ft->host, "Unable to send command \"%s\" (flen=%d szBuffer=%d)",buffer,flen,strlen(buffer)); | |
477 | + lib3270_write_log(ft->host, "ft", "Unable to send command \"%s\" (flen=%d szBuffer=%ld)",buffer,flen,strlen(buffer)); | |
478 | 478 | ft_failed(ft,_( "Unable to send file-transfer request" )); |
479 | 479 | return errno = EINVAL; |
480 | 480 | } | ... | ... |
src/core/ft/ft_dft.c
... | ... | @@ -383,7 +383,7 @@ static void dft_get_request(H3270 *hSession) { |
383 | 383 | /* Binary read. */ |
384 | 384 | numread = fread(bufptr, 1, numbytes, ft->local_file); |
385 | 385 | if (numread <= 0) { |
386 | - lib3270_write_log(hSession,"Error %s reading source file (rc=%d)",strerror(errno),errno); | |
386 | + lib3270_write_log(hSession,"ft","Error %s reading source file (rc=%d)",strerror(errno),errno); | |
387 | 387 | break; |
388 | 388 | } |
389 | 389 | ... | ... |
src/core/keyboard/kybd.c
... | ... | @@ -128,14 +128,16 @@ static const char dxl[] = "0123456789abcdef"; |
128 | 128 | * Check for typeahead availability and create a new TA structure. |
129 | 129 | * |
130 | 130 | * @return new typeahead struct or NULL if it's not available. |
131 | + * @retval NULL Host is not connected or malloc error. | |
131 | 132 | */ |
132 | 133 | struct ta * new_ta(H3270 *hSession, enum _ta_type type) { |
133 | - struct ta *ta; | |
134 | + struct ta *ta = NULL; | |
134 | 135 | |
135 | 136 | // If no connection, forget it. |
136 | 137 | if (!lib3270_is_connected(hSession)) { |
137 | 138 | lib3270_ring_bell(hSession); |
138 | 139 | lib3270_write_event_trace(hSession,"typeahead action dropped (not connected)\n"); |
140 | + errno = ENOTCONN; | |
139 | 141 | return NULL; |
140 | 142 | } |
141 | 143 | |
... | ... | @@ -143,6 +145,7 @@ struct ta * new_ta(H3270 *hSession, enum _ta_type type) { |
143 | 145 | if (hSession->kybdlock & KL_OERR_MASK) { |
144 | 146 | lib3270_ring_bell(hSession); |
145 | 147 | lib3270_write_event_trace(hSession,"typeahead action dropped (operator error)\n"); |
148 | + errno = EINVAL; | |
146 | 149 | return NULL; |
147 | 150 | } |
148 | 151 | |
... | ... | @@ -150,6 +153,7 @@ struct ta * new_ta(H3270 *hSession, enum _ta_type type) { |
150 | 153 | if (hSession->kybdlock & KL_SCROLLED) { |
151 | 154 | lib3270_ring_bell(hSession); |
152 | 155 | lib3270_write_event_trace(hSession,"typeahead action dropped (scrolled)\n"); |
156 | + errno = EINVAL; | |
153 | 157 | return NULL; |
154 | 158 | } |
155 | 159 | |
... | ... | @@ -157,6 +161,7 @@ struct ta * new_ta(H3270 *hSession, enum _ta_type type) { |
157 | 161 | if (!hSession->typeahead) { |
158 | 162 | lib3270_ring_bell(hSession); |
159 | 163 | lib3270_write_event_trace(hSession,"typeahead action dropped (no typeahead)\n"); |
164 | + errno = EINVAL; | |
160 | 165 | return NULL; |
161 | 166 | } |
162 | 167 | ... | ... |
src/core/see.c
... | ... | @@ -180,47 +180,47 @@ const char * see_attr(unsigned char fa) { |
180 | 180 | buf[0] = '\0'; |
181 | 181 | |
182 | 182 | if (fa & FA_PROTECT) { |
183 | - (void) strcat(buf, paren); | |
184 | - (void) strcat(buf, "protected"); | |
183 | + (void) strncat(buf, paren, 255); | |
184 | + (void) strncat(buf, "protected", 255); | |
185 | 185 | paren = ","; |
186 | 186 | if (fa & FA_NUMERIC) { |
187 | - (void) strcat(buf, paren); | |
188 | - (void) strcat(buf, "skip"); | |
187 | + (void) strncat(buf, paren, 255); | |
188 | + (void) strncat(buf, "skip", 255); | |
189 | 189 | paren = ","; |
190 | 190 | } |
191 | 191 | } else if (fa & FA_NUMERIC) { |
192 | - (void) strcat(buf, paren); | |
193 | - (void) strcat(buf, "numeric"); | |
192 | + (void) strncat(buf, paren, 255); | |
193 | + (void) strncat(buf, "numeric", 255); | |
194 | 194 | paren = ","; |
195 | 195 | } |
196 | 196 | switch (fa & FA_INTENSITY) { |
197 | 197 | case FA_INT_NORM_NSEL: |
198 | 198 | break; |
199 | 199 | case FA_INT_NORM_SEL: |
200 | - (void) strcat(buf, paren); | |
201 | - (void) strcat(buf, "detectable"); | |
200 | + (void) strncat(buf, paren, 255); | |
201 | + (void) strncat(buf, "detectable", 255); | |
202 | 202 | paren = ","; |
203 | 203 | break; |
204 | 204 | case FA_INT_HIGH_SEL: |
205 | - (void) strcat(buf, paren); | |
206 | - (void) strcat(buf, "intensified"); | |
205 | + (void) strncat(buf, paren, 255); | |
206 | + (void) strncat(buf, "intensified", 255); | |
207 | 207 | paren = ","; |
208 | 208 | break; |
209 | 209 | case FA_INT_ZERO_NSEL: |
210 | - (void) strcat(buf, paren); | |
211 | - (void) strcat(buf, "nondisplay"); | |
210 | + (void) strncat(buf, paren, 255); | |
211 | + (void) strncat(buf, "nondisplay", 255); | |
212 | 212 | paren = ","; |
213 | 213 | break; |
214 | 214 | } |
215 | 215 | if (fa & FA_MODIFY) { |
216 | - (void) strcat(buf, paren); | |
217 | - (void) strcat(buf, "modified"); | |
216 | + (void) strncat(buf, paren, 255); | |
217 | + (void) strncat(buf, "modified", 255); | |
218 | 218 | paren = ","; |
219 | 219 | } |
220 | 220 | if (strcmp(paren, "(")) |
221 | - (void) strcat(buf, ")"); | |
221 | + (void) strncat(buf, ")", 255); | |
222 | 222 | else |
223 | - (void) strcpy(buf, "(default)"); | |
223 | + (void) strncpy(buf, "(default)", 255); | |
224 | 224 | |
225 | 225 | return buf; |
226 | 226 | } |
... | ... | @@ -293,24 +293,24 @@ static const char * see_validation(unsigned char setting) { |
293 | 293 | |
294 | 294 | (void) strcpy(buf, ""); |
295 | 295 | if (setting & XAV_FILL) { |
296 | - (void) strcat(buf, paren); | |
297 | - (void) strcat(buf, "fill"); | |
296 | + (void) strncat(buf, paren, 63); | |
297 | + (void) strncat(buf, "fill", 63); | |
298 | 298 | paren = ","; |
299 | 299 | } |
300 | 300 | if (setting & XAV_ENTRY) { |
301 | - (void) strcat(buf, paren); | |
302 | - (void) strcat(buf, "entry"); | |
301 | + (void) strncat(buf, paren, 63); | |
302 | + (void) strncat(buf, "entry", 63); | |
303 | 303 | paren = ","; |
304 | 304 | } |
305 | 305 | if (setting & XAV_TRIGGER) { |
306 | - (void) strcat(buf, paren); | |
307 | - (void) strcat(buf, "trigger"); | |
306 | + (void) strncat(buf, paren, 63); | |
307 | + (void) strncat(buf, "trigger", 63); | |
308 | 308 | paren = ","; |
309 | 309 | } |
310 | 310 | if (strcmp(paren, "(")) |
311 | - (void) strcat(buf, ")"); | |
311 | + (void) strncat(buf, ")", 63); | |
312 | 312 | else |
313 | - (void) strcpy(buf, "(none)"); | |
313 | + (void) strncpy(buf, "(none)", 63); | |
314 | 314 | return buf; |
315 | 315 | } |
316 | 316 | |
... | ... | @@ -320,29 +320,29 @@ static const char * see_outline(unsigned char setting) { |
320 | 320 | |
321 | 321 | (void) strcpy(buf, ""); |
322 | 322 | if (setting & XAO_UNDERLINE) { |
323 | - (void) strcat(buf, paren); | |
324 | - (void) strcat(buf, "underline"); | |
323 | + (void) strncat(buf, paren, 63); | |
324 | + (void) strncat(buf, "underline", 63); | |
325 | 325 | paren = ","; |
326 | 326 | } |
327 | 327 | if (setting & XAO_RIGHT) { |
328 | - (void) strcat(buf, paren); | |
329 | - (void) strcat(buf, "right"); | |
328 | + (void) strncat(buf, paren, 63); | |
329 | + (void) strncat(buf, "right", 63); | |
330 | 330 | paren = ","; |
331 | 331 | } |
332 | 332 | if (setting & XAO_OVERLINE) { |
333 | - (void) strcat(buf, paren); | |
334 | - (void) strcat(buf, "overline"); | |
333 | + (void) strncat(buf, paren, 63); | |
334 | + (void) strncat(buf, "overline", 63); | |
335 | 335 | paren = ","; |
336 | 336 | } |
337 | 337 | if (setting & XAO_LEFT) { |
338 | - (void) strcat(buf, paren); | |
339 | - (void) strcat(buf, "left"); | |
338 | + (void) strncat(buf, paren, 63); | |
339 | + (void) strncat(buf, "left", 63); | |
340 | 340 | paren = ","; |
341 | 341 | } |
342 | 342 | if (strcmp(paren, "(")) |
343 | - (void) strcat(buf, ")"); | |
343 | + (void) strncat(buf, ")", 63); | |
344 | 344 | else |
345 | - (void) strcpy(buf, "(none)"); | |
345 | + (void) strncpy(buf, "(none)", 63); | |
346 | 346 | return buf; |
347 | 347 | } |
348 | 348 | ... | ... |
src/mkfb/mkfb.c
... | ... | @@ -509,11 +509,18 @@ main(int argc, char *argv[]) { |
509 | 509 | |
510 | 510 | /* Open the output file. */ |
511 | 511 | if (argc == 3) { |
512 | - o = fopen(argv[2], "w"); | |
512 | + int fd = creat(argv[2], S_IWUSR | S_IRUSR); | |
513 | + if(fd < 0) { | |
514 | + perror(argv[2]); | |
515 | + exit(1); | |
516 | + } | |
517 | + | |
518 | + o = fdopen(fd,"w"); | |
513 | 519 | if (o == NULL) { |
514 | 520 | perror(argv[2]); |
515 | 521 | exit(1); |
516 | 522 | } |
523 | + | |
517 | 524 | } else |
518 | 525 | o = stdout; |
519 | 526 | ... | ... |