Skip site navigation (1) Skip section navigation (2)

StrNCpy

From: "Maurice Gittens" <mgittens(at)gits(dot)nl>
To: <hackers(at)postgreSQL(dot)org>
Subject: StrNCpy
Date: 1998-03-31 09:12:07
Message-ID: 006201bd5c85$145d3360$fcf3b2c2@caleb..gits.nl (view raw or flat)
Thread:
Lists: pgsql-hackers
Hi,

While debugging yet another overrun I came across the StrNCpy macro.
A quick grep of the source tells me that usage of the StrNCpy macro is
seemingly inconsistent.

Usage 1:
strptr = palloc(len);    // done is a diffrent context
ptr = palloc(len + 1);
StrNCpy(ptr, strptr, len + 1);

Usage 2:
NameData name;
StrNCpy(name.data, ptr2name, NAMEDATALEN);

The StrNCpy macro zero terminates the destination buffer.

Usage 1 is gives a read=buffer overrun (which I agree is not the most
serious of bugs
if you system doesn't dump core on it).
Usage 2 makes gives the name a maximum of 31 instead of 32 characters.

Is the maximun name length supposted to be 31 or 32 characters?

With regards from Maurice.


Responses

pgsql-hackers by date

Next:From: BoersenspielteamDate: 1998-03-31 12:30:35
Subject: Re: [HACKERS] Reminder: Indices are not used
Previous:From: Goran ThyniDate: 1998-03-31 08:56:03
Subject: free-text searching

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group