ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_db.c
(Generate patch)

Comparing ircd-hybrid/trunk/src/conf_db.c (file contents):
Revision 1625 by michael, Thu Nov 1 13:49:25 2012 UTC vs.
Revision 1626 by michael, Thu Nov 1 17:21:59 2012 UTC

# Line 177 | Line 177 | open_db_write(const char *service, const
177    unlink(filename);
178  
179    /* Use open() to avoid people sneaking a new file in under us */
180 <  fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0666);
181 <  f->fp = fdopen(fd, "wb");   /* will fail and return NULL if fd < 0 */
180 >  if ((fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0666)) >= 0)
181 >    f->fp = fdopen(fd, "wb");
182  
183    if (!f->fp || !write_file_version(f, version))
184    {
# Line 332 | Line 332 | close_db(struct dbFILE *f)
332   * and read pointers are returned as either (void *)0 or (void *)1.  A
333   * string is stored with a 2-byte unsigned length (including the trailing
334   * \0) first; a length of 0 indicates that the string pointer is NULL.
335 < * Written strings are truncated silently at 65534 bytes, and are always
335 > * Written strings are truncated silently at 4294967294 bytes, and are always
336   * null-terminated.
337   */
338  
# Line 545 | Line 545 | int
545   read_string(char **ret, struct dbFILE *f)
546   {
547    char *s = NULL;
548 <  uint16_t len = 0;
548 >  uint32_t len = 0;
549  
550 <  if (read_uint16(&len, f) < 0)
550 >  if (read_uint32(&len, f) < 0)
551      return -1;
552  
553    if (len == 0)
# Line 580 | Line 580 | write_string(const char *s, struct dbFIL
580    uint32_t len = 0;
581  
582    if (!s)
583 <    return write_uint16(0, f);
583 >    return write_uint32(0, f);
584  
585    len = strlen(s);
586  
587 <  if (len > 65534)
588 <    len = 65534;
589 <  if (write_uint16((uint16_t)(len + 1), f) < 0)
587 >  if (len > 4294967294)
588 >    len = 4294967294;
589 >  if (write_uint32(len + 1, f) < 0)
590      return -1;
591    if (len > 0 && fwrite(s, 1, len, f->fp) != len)
592      return -1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines