Re: pgsql 8.0 beta1 patch for token and timezone

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Zhong Jacky <jackyzhongxp(at)msn(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: pgsql 8.0 beta1 patch for token and timezone
Date: 2004-10-07 17:17:56
Message-ID: 29981.1097169476@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> + /*
> + * Escape any single quotes or backslashes in locale
> + */
> + static void
> + escape_locale(char **locale)
> + {
> + int len = strlen(*locale),
> + i, j;
> + char *loc_temp = xmalloc(len * 2);
> +
> + for (i = 0, j = 0; i < len; i++)
> + {
> + if ((*locale)[i] == '\'' || (*locale)[i] == '\\')
> + loc_temp[j++] = '\\';
> + loc_temp[j++] = (*locale)[i];
> + }
> + *locale = loc_temp;
> + }

Surely this is quite broken. You need to xmalloc one more byte and
add a '\0'.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2004-10-07 17:29:11 Re: pgsql 8.0 beta1 patch for token and timezone
Previous Message Bruce Momjian 2004-10-07 16:52:37 Re: pgsql 8.0 beta1 patch for token and timezone