Skip to content

Commit

Permalink
config: Make sure to limit unterminated string
Browse files Browse the repository at this point in the history
Signed-off-by: Hubert Figuière <hub@figuiere.net>
  • Loading branch information
hfiguiere authored and msmeissn committed Feb 3, 2025
1 parent c5587ba commit 5a3491f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions camlibs/ptp2/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -8386,15 +8386,16 @@ static int
_get_STR_as_time(CONFIG_GET_ARGS) {
time_t camtime;
struct tm tm;
char capture_date[64],tmp[5];
char capture_date[65],tmp[5];

/* strptime() is not widely accepted enough to use yet */
memset(&tm,0,sizeof(tm));
if (!dpd->CurrentValue.str)
return (GP_ERROR);
gp_widget_new (GP_WIDGET_DATE, _(menu->label), widget);
gp_widget_set_name (*widget, menu->name);
strncpy(capture_date,dpd->CurrentValue.str,sizeof(capture_date));
strncpy(capture_date,dpd->CurrentValue.str,sizeof(capture_date) - 1);
capture_date[64] = 0;
strncpy (tmp, capture_date, 4);
tmp[4] = 0;
tm.tm_year=atoi (tmp) - 1900;
Expand Down

0 comments on commit 5a3491f

Please sign in to comment.