php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #566 pg_lowrite will not handle nulls in the data
Submitted: 1998-07-22 06:02 UTC Modified: 1998-07-22 10:15 UTC
From: scott at elysium dot demon dot co dot uk Assigned:
Status: Closed Package: PostgreSQL related
PHP Version: 3.0.2 OS: Linux 2.0
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: scott at elysium dot demon dot co dot uk
New email:
PHP Version: OS:

 

 [1998-07-22 06:02 UTC] scott at elysium dot demon dot co dot uk
It seems that the pg_lowrite function was using strlen() to calculate the amount of data to write. This meant that it would not write data correctly if there was a null byte in it. This can be fixed by the following patch which changes it to use the str->value.str.len variable for the amount of data to write.

*** pgsql.c.orig        Mon Jun 29 13:36:54 1998
--- pgsql.c     Wed Jul 22 10:28:10 1998
***************
*** 1311,1316 ****
--- 1311,1317 ----
                        id = pgsql_id->value.lval;
                        convert_to_string(str);
                        buf = str->value.str.val;
+                       buf_len = str->value.str.len;
                        break;
                default:
                        WRONG_PARAM_COUNT;
***************
*** 1323,1329 ****
                RETURN_FALSE;
        }
  
-       buf_len = strlen(buf);
        if ((nbytes = lo_write((PGconn *)pgsql->conn, pgsql->lofd, buf, buf_len))==-1) {
                RETURN_FALSE;
        }
--- 1324,1329 ----

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-07-22 10:15 UTC] rasmus
Applied - thanks for catching that
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 13 11:01:27 2025 UTC